How do I change a objects sprite in gamemaker based on its direction on movement in Game Maker?

I am making a maze game in game maker v1.4.1763, and need some help changing a objects sprite based on its direction of movement. I am currently have an object following the mouse using game makers drag and drop 'move towards" action. I have sprites that are animated for the object from 4 different perspectives(front, back, left, and right.) The object can move in any direction (It doesn't have to stick to the cardinal directions.) I want the object to change its sprite based on witch way it is "mostly" moving. I don't really know how to program using game makers language, but I know how to get it to execute code. I have tried almost everything using the drag and drop coding and this can only be accomplished using some code. If someone could help me come up with that code, that would be awesome.

38.3k 26 26 gold badges 201 201 silver badges 275 275 bronze badges asked Dec 13, 2016 at 19:32 21 1 1 silver badge 2 2 bronze badges

1 Answer 1

if direction > 45 and direction 135 and direction 225 and direction  

Where spr_left , spr_right , spr_up , spr_down is your sprites. You can place this code in Step End event.

answered Dec 14, 2016 at 4:18 1,777 1 1 gold badge 13 13 silver badges 25 25 bronze badges

Related

Hot Network Questions

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.9.4.14806