chore: clean up animated frameRect calc
This commit is contained in:
parent
654a9b4dd8
commit
4a4a624d9e
|
@ -47,17 +47,19 @@ class AnimatedBase extends Trait {
|
|||
];
|
||||
}
|
||||
|
||||
updateFrameRect() {
|
||||
if (this.sprite) {
|
||||
this.sprite.sourceRectangle = this.frameRect;
|
||||
}
|
||||
}
|
||||
|
||||
listeners() {
|
||||
return {
|
||||
currentFrameChanged: () => {
|
||||
if (this.sprite) {
|
||||
this.sprite.sourceRectangle = this.frameRect;
|
||||
}
|
||||
this.updateFrameRect();
|
||||
},
|
||||
directionChanged: () => {
|
||||
if (this.sprite) {
|
||||
this.sprite.sourceRectangle = this.frameRect;
|
||||
}
|
||||
this.updateFrameRect();
|
||||
},
|
||||
tick: (elapsed) => {
|
||||
this.frameCaret -= elapsed;
|
||||
|
@ -79,7 +81,7 @@ class AnimatedBase extends Trait {
|
|||
}
|
||||
Image.load(this.image).then((image) => {
|
||||
this.sprite = new Sprite(image);
|
||||
this.sprite.sourceRectangle = this.frameRect;
|
||||
this.updateFrameRect();
|
||||
this.entity.container.addChild(this.sprite);
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user