Game Development Reference
In-Depth Information
p.addHeroHP = function () {
var hero = new createjs.Sprite(spritesheet, 'hero');
hero.y = -15;
hero.x = 20;
this.addChild(hero);
this.hpTxt = new createjs.BitmapText('', spritesheet);
this.hpTxt.letterSpacing = 3;
this.hpTxt.x = 150;
this.hpTxt.y = 15;
this.addChild(this.hpTxt);
}
p.addButtons = function () {
var i, btn, btnWidth, prevButton;
var btns = ['attack', 'potion', 'fire', 'earth', 'lightning' ];
var player = data.PlayerData.player;
var xPos = 70;
var yPos = 140;
var btnSpacing = 5;
var len = btns.length;
this.buttonHolder = new createjs.Container();
for (i = 0; i < len; i++) {
btn = new game.BattleButton(btns[i], player[btns[i]]);
btnWidth = btn.getBounds().width;
if (prevButton != null) {
btn.x = ((prevButton.x + (prevButton.getBounds().width /
2)) + btnWidth / 2) + btnSpacing;
}
else {
btn.x = xPos;
}
btn.y = yPos;
btn.on('click', this.onAttackButtonSelected, this);
this.buttonHolder.addChild(btn);
prevButton = btn;
}
this.addChild(this.buttonHolder);
}
p.disableButtons = function () {
var i, btn;
var len = this.buttonHolder.getNumChildren();
for (i = 0; i < len; i++) {
btn = this.buttonHolder.getChildAt(i);
btn.disableButton();
}
}
p.enableButtons = function () {
var i, btn;
var len = this.buttonHolder.getNumChildren();
Search WWH ::




Custom Search