3 Adding Ghosts
Create a new sprite called spr_ghost and load the ghost graphic.
Create a new object called obj_ghost and choose the ghost sprite from the list. Make the ghost solid by clicking on the checkbox as shown.
Open up your room window again and draw 4 rows of ghosts at the top of the screen until it looks like the screenshot.
We want to make the ghosts move around on the screen. In classic Space Invaders they would all move left and right to the edge of the screen and, as soon as one invader hits the edge of the screen, all the invaders start moving in the opposite direction.
Open up the ghost object window and add a Create event. Drag in the Move Fixed icon. Click the arrow pointing to the right and set the speed to 1.
Now to work out what to do when one of the ghosts hits the edge of the screen.
Add an Event and choose Other, Intersect Boundary. This event takes place when the object is touching the edge of the screen.
If a ghost is moving off the left of the screen we want to send all of the ghosts moving to the right.
Drag in a Test Expression icon and fill in the expression to test with x<0.
Add a Start Block arrow and then a Move Fixed icon. Fill in the pop-up as shown.
Finish off with an End Block arrow so that your window looks like the screenshot.
That deals with the left hand side of the screen. Add a Test Expression icon. The expression to see if the ghosts are hitting the right hand side of the screen is x>room_width-32.
Drag in a Start Block and then the Move Fixed icon.
When you have finished, your window should look like the screenshot,
Save your game and test again to see if the ghosts are moving as you expected.