Step 8: Making more buttons work

To make the buttons on pages 2 and 3 work, we need to edit the page script, and check which button was pressed when the page number = 2 and when the page number = 3.

Find the "When a message of button pressed is retrieved" block.

We can see that it is only checking if the page number = 1, so we'll have to add more to this. Click on the cog on that first "if" block, and drag two "else if" blocks into the "if" block.

Duplicate the "number page number = 1" blocks twice, and drag them both into the empty "else if" slots.

Duplicate the blocks that check which button was pressed, and drag them below page number = 2 and page number = 3.

We don't need the functions inside the page number = 2 and page number = 3 sections, so we can get rid of those.

If the player is on page 2, and they press button 1, we need to display a new page. We don't yet have functions for pages 4 and 5, but we can duplicate the function for page 3, and use that for page 4 and page 5.

Since I'm not sure what's going to be on page 4 and page 5, I've just typed ??? in the text fields.

Drawing a flowchart like this might help you to plan your story:

In my example story, on page 2 the ship's lights turn on, and the player can press button 1 to enter the ship, or press button 2 to fire. If they enter the ship, they'll be taken to page 4 where they find treasure and a message. If they fire at the ship, they'll be taken to page 5 where they'll be shot back by the ship, and lose the game.

Once you know what to write in page 4 and page 5, you can fill out the text fields in those functions.

With the help of my flowchart, I now know which functions should go inside my "if-else" blocks.

This explains the basic pick-a-path method required to display the pages of a story, and how to use buttons to take you to new pages that themselves have buttons in them.

You can continue adding more pages until you come to the end of your story.

You can play my example game here:

http://gamefroot.com/game/pick-a-path-game/

If you'd like to grab a copy of this game, you can click the Remix button underneath the game. Then you can explore the scripts that make it work.

results matching ""

    No results matching ""