Game Development Reference
In-Depth Information
Listing 14-30. BattlePanel.js - The Complete BattlePanel Class
(function () {
window.game = window.game || {}
function BattlePanel(hero) {
this.hero = hero;
this.initialize();
}
var p = BattlePanel.prototype = new createjs.Container();
p.Container_initialize = p.initialize;
p.SPEED = 8;
p.hero = null;
p.waitBar = null;
p.buttonHolder = null;
p.hpTxt = null;
p.waitingToAttack = null;
p.currentAttackButton = null;
p.initialize = function () {
this.Container_initialize();
this.addWaitBar();
this.addBG();
this.addHeroHP();
this.addButtons();
this.disableButtons();
}
p.addWaitBar = function () {
var progressWidth = 365;
var progressBG = new createjs.Shape();
this.waitingToAttack = false;
this.waitBar = new createjs.Shape();
progressBG.graphics.beginFill('#b6b6b6').drawRect(0, 0,
progressWidth, 40);
this.waitBar.graphics.beginFill('#45c153').drawRect(0, 0,
progressWidth, 40);
this.waitBar.scaleX = 0;
progressBG.x = this.waitBar.x = screen_width - progressWidth;
this.addChild(progressBG, this.waitBar);
}
p.addBG = function () {
var bg = new createjs.Sprite(spritesheet, 'battlePanel');
this.addChild(bg);
}
Search WWH ::




Custom Search