Checking movement direction for animation change

For questions about using Classic.

Post » Tue Nov 17, 2009 3:39 pm

I'm working a simple game in which I have some mobs that wander in a random direction for a random amount of time. For this I applied a custom movement behavior and and use the "Change speed towards angle" with the speed set to a global variable and angle is "random(360). This part works great and does what it needs to do. The problem that I am having is trying to figure out how to change the animation based on the direction of the enemy on the X axis ( a simple left or right). I don't know how to perform a check based on direction.

I tried to search for a solution to this, but I'm no programmer I don't know the proper terminology to even search for, so if there is a post about this already, I apologize and help whatsoever will be greatly appreciated.

Thanks
B
1
G
3
Posts: 2
Reputation: 829

Post » Tue Nov 17, 2009 4:09 pm

Make a variable, old_x

+ old_x is greater than sprite.x
> change animation to "left"
+ old_x is less than sprite.x
> change animation to "right"
+ always
> set old_x to sprite.x

Guess what this does!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Nov 18, 2009 2:04 am

...or in the event you set the angle, add two subevents (system compare, else):

(system compare) AngleDiff(0,mob.angle) less or equal than 90
+change animation to "right"
else
+change animation to "left"

Edit: forgot to type what to compare to :s
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Nov 18, 2009 3:36 am

Sweet guys... I appreciate the help here. I will try these suggestions and let ya know if it worked or not.

Thanks again.
B
1
G
3
Posts: 2
Reputation: 829


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests