私は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();
は私のループに入っているので、あなたが期待する方法を更新しています。