Jump to content


Photo

stop mouse movement when going at a certain y


  • Please log in to reply
6 replies to this topic

#1 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 01 March 2012 - 01:34 PM

i have the mouse hidden and an object following it(crosshair). i need the mouse stop moving when reaching a y .
now i think there r 2 ways.
1) when it collides with my borderline.
or
2) stop under certain y.

because i searched a little i don't think there is a code that ll stop(effect) the mouse directly.
not the sprite movement, the MOUSE.is there?

thx for reading and ur time.

Edited by Morpheas, 01 March 2012 - 02:49 PM.

  • 0

#2 Noele

Noele

    GMC Mentor

  • GMC Member
  • 2353 posts
  • Version:GM8.1

Posted 01 March 2012 - 04:18 PM

window_mouse_get_x() Returns the x-coordinate of the mouse in the window.
window_mouse_get_y() Returns the y-coordinate of the mouse in the window.
window_mouse_set(x,y) Sets the position of the mouse in the window to the indicated values.

Using these functions you can test and set the y position of the mouse in the current window.
  • 0

#3 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 01 March 2012 - 05:55 PM

window_mouse_get_x() Returns the x-coordinate of the mouse in the window.
window_mouse_get_y() Returns the y-coordinate of the mouse in the window.
window_mouse_set(x,y) Sets the position of the mouse in the window to the indicated values.

Using these functions you can test and set the y position of the mouse in the current window.


because im a newbie can u tell me an example of the code and in what event i ll put it.
i mean in a step event probably and in crosshair object?and an example pls.
because im stuck with a mouse borderline(y) shaker:P

more info about my game:
its not full screen.
i want to move the mouse freely in my window but not under a certain y.
thx for ur time.
if u help me i ll give u a + :).

Edited by Morpheas, 01 March 2012 - 06:04 PM.

  • 0

#4 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 02 March 2012 - 09:15 AM

any help pls?
  • 0

#5 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 03 March 2012 - 10:16 AM

Here, put this on STEP event of the object if that's what you mean:
x=mouse_x
y=mouse_y

if x>number1 x=number1 //if x is larger than some number, x is equal to that number.
if y>number2 y=number2 //if y is larger than some number, y is equal to that number.

example: if x>200 x=200 ; if y>150 y=150 ;

thx for this code.but this code effects the sprite not the mouse.as i said above i want something that effects the mouse.
but thx for ur time and help
  • 0

#6 Noele

Noele

    GMC Mentor

  • GMC Member
  • 2353 posts
  • Version:GM8.1

Posted 03 March 2012 - 12:38 PM

You could try:
Step Event (of something)
if(window_mouse_get_y() > 500){ // alter the 500 to the max you want
  window_mouse_set(window_mouse_get_x(), 500); // places the mouse back to 500 max.
}
If the current mouse Y position in the game window is greater than 500 then the mouse Y position is set at 500, thus preventing the mouse going outside whatever max you set.
You can also prevent it moving less than a specific Y.
if(window_mouse_get_y()< 32){ // alter the 32 to the min Y you want
  window_mouse_set(window_mouse_get_x(), 32); // places the mouse back to 32 mimimum.
}
Note that GM adapts the display when running in full screen so the x,y mouse positions in the window can vary.
  • 1

#7 Morpheas

Morpheas

    GMC Member

  • New Member
  • 66 posts
  • Version:GM8

Posted 04 March 2012 - 09:40 AM

that worked like a charm thx
i found why i had the previous shaker effect.it wanted the
window_mouse_get_y() code 1st and then the jump to position....not other way around.......:)

Edited by Morpheas, 04 March 2012 - 11:07 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users