diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index cb27d8fce4..e963f50dd0 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -18,7 +18,7 @@ Sprite::Sprite() m_pTexture = NULL; m_bDrawIfTextureNull = false; m_iCurState = 0; - m_fSecsIntoState = 0.0; + m_fSecsIntoState = m_fLastTime = 0.0f; m_bUsingCustomTexCoords = false; m_fRememberedClipWidth = -1; @@ -283,7 +283,26 @@ void Sprite::Update( float fDelta ) if( !m_pTexture ) // no texture, nothing to animate return; - m_fSecsIntoState += fDelta; + float fTimePassed = 0; + switch( m_EffectClock ) + { + case CLOCK_TIMER: + fTimePassed = fDelta; + break; + + case CLOCK_BGM_BEAT: + fTimePassed = g_fCurrentBGMBeat - m_fLastTime; + m_fLastTime = g_fCurrentBGMBeat; + break; + + case CLOCK_BGM_TIME: + fTimePassed = g_fCurrentBGMTime - m_fLastTime; + m_fLastTime = g_fCurrentBGMTime; + break; + default: FAIL_M( ssprintf("%i",m_EffectClock) ); + } + + m_fSecsIntoState += fTimePassed; UpdateAnimationState(); // @@ -627,7 +646,7 @@ void Sprite::SetState( int iNewState ) CLAMP(iNewState, 0, (int)m_States.size()-1); m_iCurState = iNewState; - m_fSecsIntoState = 0.0; + m_fSecsIntoState = m_fLastTime = 0.0f; } float Sprite::GetAnimationLengthSeconds() const diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 37f1e57592..d80b460039 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -79,6 +79,7 @@ protected: vector m_States; int m_iCurState; float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame + float m_fLastTime; bool m_bUsingCustomTexCoords; float m_CustomTexCoords[8]; // (x,y) * 4: top left, bottom left, bottom right, top right