looping behaviour mirrored in preview
parent
90ca7333c8
commit
8e62001389
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue