@@ -14,7 +14,7 @@ export class SpriteAnimation extends TextureBasedEntity {
1414 duration : 1000 ,
1515 playing : true ,
1616 restarted : null ,
17- animationProgressTime : 0 ,
17+ animationProgress : 0 ,
1818 date : 0
1919 } )
2020 }
@@ -35,12 +35,10 @@ export class SpriteAnimation extends TextureBasedEntity {
3535 super . updateDisplay ( state , changed , globalData )
3636
3737 if ( state . images ) {
38- const duration = state . duration
3938 const images = state . images . split ( ',' )
4039
41- const animationProgress = ( state . loop ? unlerpUnclamped : unlerp ) ( 0 , duration , state . animationProgressTime )
42- if ( animationProgress >= 0 ) {
43- const animationIndex = Math . floor ( images . length * animationProgress )
40+ if ( state . animationProgress >= 0 ) {
41+ const animationIndex = Math . floor ( images . length * state . animationProgress )
4442 const image = state . loop ? images [ animationIndex % images . length ] : ( images [ animationIndex ] || images [ images . length - 1 ] )
4543 try {
4644 this . graphics . texture = PIXI . Texture . fromFrame ( image )
@@ -55,11 +53,11 @@ export class SpriteAnimation extends TextureBasedEntity {
5553
5654 computeAnimationProgressTime ( prevState , currState ) {
5755 if ( currState . restarted && currState . restarted . date === currState . date ) {
58- currState . animationProgressTime = 0
56+ currState . animationProgress = 0
5957 } else {
60- currState . animationProgressTime = prevState . animationProgressTime
58+ currState . animationProgress = prevState . animationProgress
6159 if ( prevState . playing ) {
62- currState . animationProgressTime += currState . date - prevState . date
60+ currState . animationProgress += ( currState . date - prevState . date ) / prevState . duration
6361 }
6462 }
6563 }
0 commit comments