looping behaviour mirrored in preview

master
Beau Blyth 2019-09-30 21:56:49 -07:00
parent 90ca7333c8
commit 8e62001389
1 changed files with 11 additions and 1 deletions

View File

@ -52,7 +52,14 @@ export class FrameHandler {
public AdvanceFrames(amount: number) {
this.currentFrame += amount;
this.currentFrame %= this.filenames.length;
if (this.animationData.loop || !this.playingAnimation) {
this.currentFrame %= this.filenames.length;
} else {
if (this.currentFrame > this.filenames.length - 1) {
this.playingAnimation = false;
this.currentFrame = Math.min(this.currentFrame, this.filenames.length - 1);
}
}
if (this.currentFrame < 0) {
this.currentFrame = this.filenames.length - 1;
}
@ -67,6 +74,9 @@ export class FrameHandler {
public TogglePlayingAnimation() {
this.playingAnimation = !this.playingAnimation;
if (this.playingAnimation && this.currentFrame == this.filenames.length - 1 && !this.animationData.loop) {
this.currentFrame = -1;
}
console.log('playingAnimation = ', this.playingAnimation);
}
public StopPlayingAnimation() {