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

Make an animation last a fixed amount of time (The animation is triggered when pressing a button)

YaCCBoy

Member
I don't really know how to explain this as I am quite new to this. Basically, when I left-click, my character throws a pebble. I would like the pebble throwing animation to last a fixed amount of time, but presently it seems to be a weird mix of if my character is in the air and how long I keep my left-click button pressed.

code.png
spr_player_shoot is the sprite that I would like to last a fixed amount of time
 

TheouAegis

Member
Make sure you set image_index to 0 when you change the sprite. As for making the animation end on time, you can use the Animation End Event, an alarm, or a custom timer.
 

YaCCBoy

Member
Make sure you set image_index to 0 when you change the sprite. As for making the animation end on time, you can use the Animation End Event, an alarm, or a custom timer.
How can I use an alarm for this? As I said I am very new to this, I have next to no programming experience.
 

TheouAegis

Member
Before you change the sprite, check if the alarm is < 1, then set the alarm and change the sprite. Then create an alarm event and in it set the sprite back to whatever you need to.
 

YaCCBoy

Member
Could you write a code example of this please? I do not know how to set it, and my attempts with my limited knowledge failed.
Before you change the sprite, check if the alarm is < 1, then set the alarm and change the sprite. Then create an alarm event and in it set the sprite back to whatever you need to.
 
Top