Page 1 of 1

xmouse ymouse glitch, or im i not writing this right?

PostPosted: Mon Apr 20, 2009 11:14 pm
by jimmynewguy
i have this code to make the the actor walk facing the mouse based off only 4 directions.
it works with objects, but when i use it on xmouse ymouse it glitches and the player only sometimes walks the right direction
can anyone help me? thank you very much.
it's not really nesesary(wow i suck i spelling) but it's rather annoying

Code: Select all
angle = direction(x, y, xmouse, ymouse);
if(angle < 45 || angle > 315)ChangeAnimation("Event Actor", "walkEast", FORWARD);
if(angle > 45&&angle < 135)ChangeAnimation("Event Actor", "walkNorth", FORWARD);
if(angle > 135&&angle < 225)ChangeAnimation("Event Actor", "walkWest", FORWARD);
if(angle > 225&&angle < 315)ChangeAnimation("Event Actor", "walkSouth", FORWARD);

Re: xmouse ymouse glitch, or im i not writing this right?

PostPosted: Tue Apr 21, 2009 1:42 am
by DST
I have found that there are problems when using distance/direction on xmouse/ymouse.

I have always made it a habit to create a cursor actor, who follows the mouse but has mousebuttondown events disabled, and using its xy instead.

I've seen this many times and the cursor actor has always been my solution.


Another benefit to cursor actor is you can use it for mouseover in/out events by (for instance, making a button light up) by changing its [the button's] animation on collision with cursor actor (repeat) and then returning it to normal on collision finish.

Re: xmouse ymouse glitch, or im i not writing this right?

PostPosted: Tue Apr 21, 2009 8:34 pm
by jimmynewguy
thanx DST, i don't know why i didn't think of it, since i used in an older version of the game :roll: i will have to come up with a cool cursor.............