• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Problem object following mouse when try to press on screen GUI Button

X

Xecries

Guest
hi guys.

i made this game for android but i have a problem with the player control

Step Event:
execute code:

move_towards_point(mouse_x,mouse_y-50,8);
if point_distance(x,y,mouse_x,mouse_y-50)<speed
{
direction = 0;
speed = 0;
}

The code is for the player which is constantly following the mouse. so when i created a button and put it in the room and tried to press it like shoot missile the player move toward the place that i press. How can i avoid the player to move its position when i am pressing a button. I have tried using simple code like doom mouse_click but it prevents the player unique move freely in the screen.
[/url][/IMG]
[/url][/IMG]Fire_porblem.png
 
Last edited by a moderator:
Z

Zefyrinus

Guest
So you want the player to constantly move towards the mouse, except when you're clicking? If that's all, you could do like:
Code:
if(move == true)
{
move_towards_point(mouse_x,mouse_y-50,8);
if point_distance(x,y,mouse_x,mouse_y-50)<speed
{
direction = 0;
speed = 0;
}
}
And then have a mouse press event where you set Player*.move = false. You also need to set move = true again at some point, maybe a mouse release event. I'm not sure how these different mouse events affect each other. :confused: The mouse events are also only executed if the mouse pointer is within the bounding box of the object where these events happen. You said something about clicking a button? In that case the mouse events should be in the button object.
*Or whatever the name of your player object is.
 
Top