• 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!

GameMaker How to detect moments in a animation sprite?

Suzaku

Member
Lets suppose that I have a object that represents a lady character:
upload_2019-5-27_18-20-26.png


and I have this animated sprite:
upload_2019-5-27_18-24-7.png

I want this character object to move a little to the right until it reach the frame 4 on that animation. Then the object must stop moving because the character will start to get up, following the animation. This is just a example but I want to do a lot of similar operations like that, where I need the object to behave differently accordly to the moment of the animation sprite.

My question is specificly about how to detect those moments where the object will do different things.

So in that example, should I keep monitoring the frames to execute a movement code whenever that sprite is between the frames zero and 4...... or should I divide the sprite into 2 sub sprites to detect those moments using the animation end event? Or is there another easy way to do such things? Thank you.
 

Attachments

Nux

GameMaker Staff
GameMaker Dev.
The way I would do it is to set the image_index of the object manually. So, you would begin to fall over and move your object to the right; during this you will slowly increment the image_index from 0 to 4. Once you reach the fourth index you would stop moving the object and begin the get up animation.

You could do this using an if-statement with a variable called "is_tripping", but a better way would be to use a state machine. You can find tutorials on state machines on youtube: https://www.youtube.com/watch?v=DYkJ91eg67Y
 
Top