BlueGit

timfa frameworkv3

fix animationcycle not cycling all frames in an animation, immediately switch subimage on animation trigger

timfa Tim · pushed by timfa

Authored 2022-10-18 · 4 years ago

Hash
3ff30a4a31f1ebcdbac0b956c7ca728ae0a44f3a
Parent
7cee4082
1 file changed +4 −3
framework/engine/objectComponents/renderer.js +4 −3
@@ -33,9 +33,8 @@ class Renderer
33 33 {
34 34 this.cycle.timer -= this.cycle.cycleSpeed;
35 35
36 this.cycle.cycleArray[this.cycle.current + 1] ?
37 this.updateCycleSprite(this.cycle.current + 1) :
38 this.updateCycleSprite(0);
36 let next = (this.cycle.current + 1) % this.cycle.cycleArray.length;
37 this.updateCycleSprite(next)
39 38 }
40 39 }
41 40 }
@@ -114,6 +113,8 @@ class Renderer
114 113 current: defaultIndex,
115 114 cycleSpeed: cycleSpeed,
116 115 timer: 0};
116
117 this.subImage = this.cycle.cycleArray[this.cycle.current];
117 118 }
118 119
119 120 setAnimationCycleSpeed(cycleSpeed)
@@ -33,9 +33,8 @@ class Renderer
33 {
33 {
34 this.cycle.timer -= this.cycle.cycleSpeed;
34 this.cycle.timer -= this.cycle.cycleSpeed;
35
35
36 this.cycle.cycleArray[this.cycle.current + 1] ?
36 let next = (this.cycle.current + 1) % this.cycle.cycleArray.length;
37 this.updateCycleSprite(this.cycle.current + 1) :
37 this.updateCycleSprite(next)
38 this.updateCycleSprite(0);
39 }
38 }
40 }
39 }
41 }
40 }
@@ -114,6 +113,8 @@ class Renderer
114 current: defaultIndex,
113 current: defaultIndex,
115 cycleSpeed: cycleSpeed,
114 cycleSpeed: cycleSpeed,
116 timer: 0};
115 timer: 0};
116
117 this.subImage = this.cycle.cycleArray[this.cycle.current];
117 }
118 }
118
119
119 setAnimationCycleSpeed(cycleSpeed)
120 setAnimationCycleSpeed(cycleSpeed)