bool AnimatedSprite::update(int time) { // Avoid freaking out at first frame or when tick_time overflows if (time < mLastTime || mLastTime == 0) mLastTime = time; // If not enough time has passed yet, do nothing if (time <= mLastTime || !mAnimation) return false; unsigned int dt = time - mLastTime; mLastTime = time; Animation *animation = mAnimation; Frame *frame = mFrame; if (!updateCurrentAnimation(dt)) { // Animation finished, reset to default play(SpriteAction::STAND); } // Make sure something actually changed return animation != mAnimation || frame != mFrame; }
void AnimatedSprite::update(int time) { // Avoid freaking out at first frame or when tick_time overflows if (time < mLastTime || mLastTime == 0) mLastTime = time; // If not enough time has passed yet, do nothing if (time <= mLastTime || !mAnimation) return; unsigned int dt = time - mLastTime; mLastTime = time; if (!updateCurrentAnimation(dt)) { // Animation finished, reset to default play(ACTION_STAND); } }