Game Development Reference
In-Depth Information
scoreBoard.createTextElement(SCORE_BOARD_CLICKED, new
SideBySideScoreElement(85, 5, 10, "Clicked", scoreBoardTextFormat,
40, "0/0", scoreBoardTextFormat));
scoreBoard.createTextElement(SCORE_BOARD_PERCENT_NEEDED, new
SideBySideScoreElement(170, 5, 10, "%Needed",scoreBoardTextFormat,
50, "0%", scoreBoardTextFormat));
scoreBoard.createTextElement(SCORE_BOARD_PERCENT_ACHIEVED, new
SideBySideScoreElement(260, 5, 10, "%Achieved",
scoreBoardTextFormat, 60, "0%", scoreBoardTextFormat));
Creating the title screen
All of the BasicScreen instances will be set up in a similar manner. All are defined in the
GameFrameWork.as file and instantiated in the Main.as init function. The first thing we do is set
up a separate TextFormat object ( screenTextFormat ) to be shared among all of the screens. We
could actually use a different TextFormat for each screen if we like, but for simplicity, we are using
one in this example game. We also create a TextFormat for SimpleBlitButton instances that can
be added to each BasicScreen instance.
screenTextFormat = new TextFormat("_sans", "16", "0xffffff", "false");
screenTextFormat.align = flash.text.TextFormatAlign.CENTER;
screenButtonFormat = new TextFormat("_sans", "12", "0x000000",
"false");
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("Super Click", 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 BasicScreen id values. The
titleScreen also accepts in the width ( 400 ), height ( 400 ), isTransparent ( false ), and color
values for the background of the screen ( 0x0000dd ).
The next task we must do when creating an instance of the BasicScreen class is decide if we
want any text or an OK button on the screen. Either of those is set up by calling the associated
public functions in the BasicScreen class. The titleScreen.createOkButton function all in Super
Click 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, and two color values. One for OFF color of the button text and one for
the OVER color. We will use black for the OFF color and red for the OVER color. 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 , Super Click, as well
as the width ( 100 ), location for the text box ( 145,150 ), and the TextFormat ( screenTextFromat ) for
the text on the screen.
Search WWH ::




Custom Search