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