Hello
What you want to do is very simple to deal in GE. In fact, you'll need only one conditional variable.
Let's call it
health (integer variable that you'll have to create in the Script Editor)
On your Healthmeter Actor :
Event CreateActor > Action Script, write :
- Code: Select all
health = 30 ; // Use 30 because of your 30-frame animation
ChangeAnimationDirection("Event Actor", STOPPED); // to stop your animation from launching at game start
animpos = 30 ; // Remember, animpos starts at 0. If your first animation sprite is numbered 0, then animpos is called from 0 to 30. Else, if it is numbered 1, animpos is called from 0 to 29. Here, let's say that it starts at frame 0
------------------------------------------------------------------------------------------
Quote :
Now how to get it to change the animation every time he looses healthOn Collision Event with each ennemy (Lasers, bullets, machine gun bullets, bombs, fire, explosions, metal cannon balls, and so on) > Action Script, write :
- Code: Select all
health = health - B ;
// where B is to be replaced by the amount of decrease you want, depending on the colliding actor
// Ex : Colliding with laser means health = health - 5, Colliding with bombs means health = health - 10, and so on
animpos = animpos - B ; // your meter animation will change animation by B frames
if (health < 0)
{
// DestroyActor
// Change animation to Explosion animation
}
Quote :
I use donuts to re-fill the healthOn Collision with Donuts, Action Script, write :
- Code: Select all
health ++ ;
animpos ++ ;
if (health > 30 )
{
health = 30 ; // to limit the meter to your 30-frame animation
}
Bingo ! Now, good luck
