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

Non-platform specific questions.

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

Postby jimmynewguy » Mon Apr 20, 2009 11:14 pm

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);
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

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

Postby DST » Tue Apr 21, 2009 1:42 am

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

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

Postby jimmynewguy » Tue Apr 21, 2009 8:34 pm

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.............
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron