【发布时间】:2013-03-16 07:15:16
【问题描述】:
我似乎完全迷失在 EaslJS 中。当我的函数被调用时,我不知道如何调整矩形的大小。
场景是这样的:我的玩家被击中,生命值减少,因此生命值条变小。
这是我创建健康栏的方法:
this.statusBar = new createjs.Shape()
this.statusBar.graphics
.beginFill("red")
.drawRect(0, 0, this.width, this.height);
this.statusBar.x = this.x+500;
this.statusBar.y = this.y;
this.statusBar.width = this.width;
this.statusBar.height = this.height;
这就是我要调整大小的地方:
this.decreaseHealth = function(amount) {
percentageLeft = (player.health/player.fullPlayerHealth)*100;
console.log(this.fullBarWidth*(percentageLeft/100));
this.statusBar.width = this.fullBarWidth*(percentageLeft/100);
}
我的stage.update(); 在我的循环中,所以它正在按照您可能期望的方式进行更新。
【问题讨论】:
标签: javascript html html5-canvas easeljs