Game Development Reference
In-Depth Information
titleScreen = new BasicScreen(FrameWorkStates.STATE_SYSTEM_TITLE,
400,400,false,0x0000dd );
titleScreen.createOkButton("OK", new Point(170, 250), 40, 20,
screenButtonFormat, 0x000000, 0xff0000,2);
titleScreen.createDisplayText("Stub Game", 100,new Point
(145,150), screenTextFormat);
The titleScreen object is created by passing in a constant for the id value of the BasicScreen
instance. We are using the FrameWorkStates constants for the BasisScreen id values. The
titleScreen also accepts in the width ( 400 ), height ( 400 ), isTransparent ( false ), and color value
for the background of the screen ( 0x0000dd ).
The next task we must complete when creating an instance of the BasicScreen class is decide if
we want any text or OK button on the screen. Those are set up by calling the associated public
functions in the BasicScreen class. The titleScreen.createOkButton function all in the stub
game creates a SimpleBlitButton instance with OK as the text of the button, 170,250 as the
location, and 20 as the width of the button. We also pass in the screenButtonFormat as the
TextFormat for the OK text, the off color as black, and the over color and red. The final number we
pass in, 2 , is a buffer amount used for positioning the text on the button.
The createDisplayText function takes in the text to put on to the titleScreen , Stub Game , as well
as the width ( 100 ), location for the text box ( 145,150 ), and the TextFormat ( screenTextFromat ) for
the text on the screen.
Creating the instructions screen
The instructionsScreen is instantiated exactly like the titleScreen only with parameter values
passed in specific to the instructions. Some of the differences you will notice are the use of the
FrameWorkStates.STATE_SYSTEM_INSTRUCTIONS for the id value of the BasicScreen instance, the
new text for the button Play , and the new text for the screen, Click the mouse\n10 times . You
will also notice that some sizes and locations have been customized for these new text values.
The “\n” character is an “escape sequence”. When placed in a String, it will force the TextField to
start a “new line” and place the text following it on this new line.
instructionsScreen = new BasicScreen(FrameWorkStates.
STATE_SYSTEM_INSTRUCTIONS,400,400, false,0x0000dd);
instructionsScreen.createOkButton("Play", new Point
(150, 250), 80, 20,screenButtonFormat, 0x000000, 0xff0000,2);
instructionsScreen.createDisplayText(
"Click the mouse\n10 times",150,new Point(120,150), screenTextFormat);
Creating the game over screen
The gameOverScreen is instantiated exactly like the instructionsScreen only with parameter
values passed in specific to the game over state. Some of the differences you will notice are the
use of the FrameWorkStates.STATE_SYSTEM_GAME_OVER for the id value of the BasicScreen
instance, the new text for the button OK, and the new text for the screen,
Game Over You will also
notice that some sizes and locations have been customized for these new text values.
Search WWH ::




Custom Search