@@ -14,7 +14,7 @@ export class SpriteAnimation extends TextureBasedEntity {
14
14
duration : 1000 ,
15
15
playing : true ,
16
16
restarted : null ,
17
- animationProgressTime : 0 ,
17
+ animationProgress : 0 ,
18
18
date : 0
19
19
} )
20
20
}
@@ -35,12 +35,10 @@ export class SpriteAnimation extends TextureBasedEntity {
35
35
super . updateDisplay ( state , changed , globalData )
36
36
37
37
if ( state . images ) {
38
- const duration = state . duration
39
38
const images = state . images . split ( ',' )
40
39
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 )
44
42
const image = state . loop ? images [ animationIndex % images . length ] : ( images [ animationIndex ] || images [ images . length - 1 ] )
45
43
try {
46
44
this . graphics . texture = PIXI . Texture . fromFrame ( image )
@@ -55,11 +53,11 @@ export class SpriteAnimation extends TextureBasedEntity {
55
53
56
54
computeAnimationProgressTime ( prevState , currState ) {
57
55
if ( currState . restarted && currState . restarted . date === currState . date ) {
58
- currState . animationProgressTime = 0
56
+ currState . animationProgress = 0
59
57
} else {
60
- currState . animationProgressTime = prevState . animationProgressTime
58
+ currState . animationProgress = prevState . animationProgress
61
59
if ( prevState . playing ) {
62
- currState . animationProgressTime += currState . date - prevState . date
60
+ currState . animationProgress += ( currState . date - prevState . date ) / prevState . duration
63
61
}
64
62
}
65
63
}
0 commit comments