Skip to content

Commit

Permalink
fix: use frameFps to control the speed of frame animation
Browse files Browse the repository at this point in the history
  • Loading branch information
JiepengTan committed Jul 18, 2024
1 parent 1b4e946 commit 1a82de7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (p *Sprite) init(
log.Panicf("animation key [%s] is exist", key)
}
oldFps := ani.Fps
oldFrameFps := ani.FrameFps
if oldFps == 0 {
ani.Fps = 25
}
Expand Down Expand Up @@ -172,8 +173,13 @@ func (p *Sprite) init(
if ani.From == nil {
ani.From, ani.To = p.getFromAnToForAniFrames(ani.From, ani.To)
}
ani.Fps = oldFps
ani.FrameFps = int(oldFps)
if oldFps == 0 && oldFrameFps != 0 {
ani.Fps = float64(oldFrameFps)
ani.FrameFps = oldFrameFps
} else {
ani.Fps = oldFps
ani.FrameFps = int(oldFps)
}
case aniTypeMove:
case aniTypeTurn:
case aniTypeGlide:
Expand Down

0 comments on commit 1a82de7

Please sign in to comment.