hello,
I was wondering for a best practise for the following example:
Player (sprite) has animation Idle and Running.
Example:
if sees enemy: play animation running
if does not see enemy: play animation idle
If player is running: play animation running
if player is not running: play animation idle
Now I think: I also want a hit animation.
The only way I know to edit the code (and insert the hit animation) is to use global or instance variables to make a clear seperation of what a player is doing and when an animation to play.
I would add:
if player overlaps SomeSprite: play animation hitting.
My example from above would change to:
if sees enemy, and does not overlap SomeSprite: play animation running
if does not see enemy: play animation idle
If player is runningand does not overlap SomeSprite: play animation running
if player is not running: play animation idle
By adding something new in the same "area", I have to edit all existing events that have to do with this. (because it effects eachother)
Can this be done easier/more efficient?