Sprites now follow the effect clock; you can sync an animated sprite

to the beat.  This can be used to implement things like the receptor
row in .sprites.  (This is minor; it's actually just a tangent of another
change which I havn't committed yet ...)
This commit is contained in:
Glenn Maynard
2004-10-16 02:15:18 +00:00
parent 3fed6a3a6e
commit 12b777c12a
2 changed files with 23 additions and 3 deletions
+22 -3
View File
@@ -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
+1
View File
@@ -79,6 +79,7 @@ protected:
vector<State> 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