Move Enemy

Wrap the Enemy

Obviously, we're working toward creating some sort of shoot-em-up space game. Right now we have to decide what we want to happen if our enemy makes it all the way across the Stage. Let's start an if statement in the moveEnemy function that checks to see if the X position is less than zero:

We'll have the enemy screen wrap using that sW (which equals Stage.width) variable we set long ago:

You should have a working project now. However, it's going to be a bit boring if the enemy always reappears at the same vertical position, so let's randomize that using the sH variable:

OK, now let's test:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player