Book Image

Creative Greenfoot: RAW

By : Michael Haungs
Book Image

Creative Greenfoot: RAW

By: Michael Haungs

Overview of this book

Table of Contents (17 chapters)
Creative Greenfoot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding menus and buttons


In this section, we will add an introduction screen and game over screen to MazeWorld. We will add a button, textbox, and menu to the introduction screen (shown in Figure 6) and just a button to the game over screen (shown in Figure 7).

Figure 6: This is the new introduction screen we are adding to MazeWorld

This is how the game over screen will look.

Figure 7: This is the new game over screen we are adding to MazeWorld

We created an introduction screen and game over screen in Chapter 1, Let's Dive Right in… and augmented the game over screen in Chapter 5, Interactive Application Design and Theory for Avoider Game, so the addition of these screens to MazeWorld will only be quickly covered here.

To start with, we are going to create a new class that both screens will inherit from. Create a new subclass of the World class and name it, MazeWorldScreens; don't associate an image with this class, and add the following code to it:

import greenfoot.*;

public class MazeWorldScreens...