Step 3/6. Adding the background obstacles
The bird can move anywhere vertically. We will end the game when the bird moves too high or too low.
In the Frame Editor > Layers Toolbar make sure that Layer 2 is selected. From the Library Window drag obstacle.Backdrop in the Frame at coordinates (0,656) right below horizon.Active. Duplicate it by holding Ctrl and drag it above the Frame at coordinates (0,-192).
- obstacle.Backdrop: background obstacle
This Quick Backdrop object is setup as Obstacle in the Object Properties > Runtime Options tab.
Your Frame should look like this:
In the Event List Editor insert a new group of events called Game.Outro and uncheck Active when frame starts. For the moment this group won't contain any event. Move this group right after the Game.Play group.
Then add the following event in the Game.Play group:
• (bird.Active) collides with the background : Play sample lose : Activate group "Game.Outro" : Deactivate group "Game.Play"
What happens with this event? When the bird hits the background obstacles we deactivate the Game.Play group where we test for the player input, preventing any further jumps. We also activate the Game.Outro group for later use.
Now add the following event after the other events in the bird.Active group:
• (bird.Active) collides with the background (bird.Active) : Stop (bird.Active) : Stop animation : Deactivate group "bird.Active"
What happens with this event? When the bird hits the background obstacles we deactivate the bird.Active group which is making him fall. We also stop its Movement and its Animation.
Note: We use two events both testing for background collisions. Please read on to find out why. It will become obvious once that we are finished dealing with the collisions.
Run the application. As soon as the bird hits one of the background obstacles, the one above the Frame or the one at the bottom of the Frame, the game is over.
Note: For easier testing use the left-most button (Rewind) of the debugger to restart the Frame.
The debugger window is displayed on the top-left corner of the screen. If you don't see it check the Application Properties > Settings tab and make sure that Show Debugger is checked.