Game Development Reference
In-Depth Information
Figure 7-3. The title sprite sdded to the stage
Building the Dice Tray
The dice tray holds all five dice, the button to trigger the roll, and a few other graphical elements. These will all be
contained within the diceTray container and are all built in the buildDiceTray function. Listing 7-10 shows the first
third of this function, which declares some variables and creates the tray container and graphics.
Listing 7-10. The buildDiceTray Function Creates the Dice Tray Container
function buildDiceTray() {
var trayBG, rollMsg, rollBtn, rollBG, rollsTxt, i, die;
var rollBtnOffset = -27;
var hGap = 60;
var xPos = 37;
var yPos = 37
//dice tray container
diceTray = new createjs.Container();
diceTray.x = DICE_TRAY_POSITION.x;
diceTray.y = DICE_TRAY_POSITION.y;
//diceTray.alpha = 0;
//tray bg
trayBG = new createjs.Sprite(spritesheet, 'diceTray');
diceTray.addChild(trayBG);
rollMsg = new createjs.Sprite(spritesheet, 'rollMessage');
rollMsg.x = trayBG.getBounds().width;
rollMsg.y = rollBtnOffset;
rollMsg.name = 'rollMsg';
//rollMsg.visible = false;
diceTray.addChild(rollMsg);
...
 
Search WWH ::




Custom Search