Game Development Reference
In-Depth Information
A Boolean (true/false) value to indicate whether or not the BitmapData will use
transparency
A color represented as an unsigned integer ( uint ).
A completely transparent background can be set for a screen by passing in true for the
isTransparent parameter and a 32-bit color value with an alpha channel set to 00 . Colors are
represented as AARRBBGG where the alpha ( AA ) values ranging from 0x00 ( 0 ) (completely
transparent) to 0xFF ( 255 ) (completely opaque) can be passed in.
The init function is used to set up the field for the display text ( displayText ) and the OK button
( okButtonSprite ). The OK button is added only if the passed in okNeeded is set to true .
The first actual line of code might be a little cryptic:
textformat1.align = flash.text.textFormayAlign.CENTER
When we set up the textFormat1 variable, we didn't set the alignment to center because not all
uses of it will be centered. We can change the alignment on the fly, and we do so here before we
apply it to the displayText field as its defaultTextFormat . Then, we simply add the text to the
screen. In the first init call, there is no text to actually add to the screen. It is added with the
setDisplytext function described next. The setDisplayText function is public and is called by the
Main class when the BasicScreen instances (title, instruction, game over, and so on) are placed
on the display list. This allows the text for the screen to be customized for each showing.
The createDisplayText function definition
By calling the createDisplayText function on a BasicScreen instance, we can turn on and set the
default location and text value for the text that displays on the BasicScreen instance. The function
adds the defaultText to the displayList with the addChild function call. The game screen is
shown in Figure 2-1.
The parameters passed into this function follow:
text : The actual text to put in the .text attribute of the defaultText TextField
location : A Point class instance that will be used to define the x and y values of the
upper left-hand corner for the defualtText TextField
width : The width in pixels of the defaultText TextField
textFormat : A TextFormat instance used to format the text in the defaultText
TextField
Search WWH ::




Custom Search