Login | Register

Animation problem

September 24, 2006, 19:11 by Calle
[loading]
-->
<b>Question:</b> "Whats the best way to make a sprite animation of someone throwing or hitting something when you press - for example - the space bar.

What I mean is, when I want a character to attack an enemy, the character will shoot something at it. I have a small animation of the character going into 'attack' mode. But the animation only goes while I am holding down the space bar. When I let go of the space bar, it goes right back - without finishing the full animation.

<b>I want to be able to just press a button and have the full animation play out once.</b> (made bold by me - Calle)


If your going to throw code at me, please let me know where to put the code as well."

<b>Answer:</b> I'll just go with the plain answer, you'll have to analyze it yourself. I don't have time for anything else!

In the space event:
att_animation = true;
if !(sprite_index==att_sprite) {
sprite_index = att_sprite;
}


Then in animation end event:
att_animation = false;

And in step, or wherever you have currently put the code which switch back you simply wrap that code which switches back with:

if (att_animation==false) {
//Switch back
}

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games