I currently have a function that, when called every 2 seconds, spawns a new enemy ship that flies towards the player. I want each ship to have 2 health points, requiring two shots by the player to kill.
The problem is, the enemy (and its health) are created each time the function is called. The problem with this is that the health of an already spawned enemy flying towards the player is then reset to 2.
I know that I need to create the sprite outside of the function with its health and then just have the function call this sprite. Unfortunately, I just don’t know how to do this.