From 1a82de7711fc989a3b3b6a41a7f68371077d254d Mon Sep 17 00:00:00 2001 From: jiepengtan Date: Thu, 18 Jul 2024 17:52:41 +0800 Subject: [PATCH] fix: use frameFps to control the speed of frame animation --- sprite.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sprite.go b/sprite.go index 28e3ab95..ade8aec8 100644 --- a/sprite.go +++ b/sprite.go @@ -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 } @@ -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: