Fix issues with Sprite animation frame updates (#6493)

This commit is contained in:
D8H
2024-04-02 21:14:48 +02:00
committed by GitHub
parent 5c66623631
commit fcc91e3fea
2 changed files with 14 additions and 4 deletions

View File

@@ -347,6 +347,7 @@ namespace gdjs {
// Make sure to delete already existing animations which are not used anymore.
this._animationFrame = null;
this.invalidateFrame();
}
updateFromObjectData(
@@ -476,16 +477,17 @@ namespace gdjs {
return this._animations[this._currentAnimation].name;
}
setAnimationName(newAnimationName: string): void {
setAnimationName(newAnimationName: string): boolean {
if (!newAnimationName) {
return;
return false;
}
for (let i = 0; i < this._animations.length; ++i) {
if (this._animations[i].name === newAnimationName) {
this.setAnimationIndex(i);
return;
return true;
}
}
return false;
}
hasAnimationEnded(): boolean {

View File

@@ -237,7 +237,15 @@ namespace gdjs {
}
setAnimationName(newAnimationName: string): void {
this._animator.setAnimationName(newAnimationName);
const hasAnimationChanged = this._animator.setAnimationName(
newAnimationName
);
if (hasAnimationChanged) {
//TODO: This may be unnecessary.
this._renderer.update();
this._animationFrameDirty = true;
this.invalidateHitboxes();
}
}
/**