Changing a Sprite When Hit in GameMaker
- by Pixels_
I am making a simple little Galaga style game. I want the objects sprite to change whenever it is hit.
For example if a laser hits an alien then the sprite takes 1 out of 4 damage to its health points (HP). However I want the sprite to change from green to yellow after 1 hit, yellow to orange after 2 hits, orange to red after 3 hits, and red to pixel explosion after all 4 HPs are lost. That way you can easily distinguish the amount of health each alien has left.
How can I do this? Preferably explain it in code.