Shooter

Please help me!
My code won’t make more than one enemy, even though it should. SOMEONE PLEASE HELP MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!

The block of code you need to look at is the huge forever loop at the far right

Hi! Try replacing it with a on game update every 5 seconds! (Or just on game update)

@DahbixLP is correct in saying that you can better use a game update interval method, if that is what your intention is (to display either an enemy of friend every 5 seconds).

I will try to explain why this is happening. The game loop just keeps occurring, so you are expecting to create multiple sprites to be either an enemy or a friend. However, in the ‘on created’ events, you are pausing the code (which means the game loop cannot proceed until the pause has finished), then the sprite is deleted, and the game loop can continue again. You have a few different options:

  1. if you want a sprite to be created every 5 seconds, move the code into a game update interval block;
  2. if you want to keep the current game loop, move the pause and delete into a separate code block that runs independent of the game loop. You need to use the ‘timers’ extension to run code separately. This does mean that many sprites are created as the game loop runs every few milliseconds (the exact amount of ms I do not know).