split out LoadStatesFromTexture
This commit is contained in:
@@ -103,6 +103,8 @@ void Sprite::Load( RageTextureID ID )
|
|||||||
{
|
{
|
||||||
if( !ID.filename.empty() )
|
if( !ID.filename.empty() )
|
||||||
LoadFromTexture( ID );
|
LoadFromTexture( ID );
|
||||||
|
|
||||||
|
LoadStatesFromTexture();
|
||||||
};
|
};
|
||||||
|
|
||||||
void Sprite::LoadFromNode( const XNode* pNode )
|
void Sprite::LoadFromNode( const XNode* pNode )
|
||||||
@@ -119,6 +121,8 @@ void Sprite::LoadFromNode( const XNode* pNode )
|
|||||||
// Load the texture
|
// Load the texture
|
||||||
LoadFromTexture( sPath );
|
LoadFromTexture( sPath );
|
||||||
|
|
||||||
|
LoadStatesFromTexture();
|
||||||
|
|
||||||
|
|
||||||
// Read in frames and delays from the sprite file,
|
// Read in frames and delays from the sprite file,
|
||||||
// overwriting the states that LoadFromTexture created.
|
// overwriting the states that LoadFromTexture created.
|
||||||
@@ -275,8 +279,25 @@ void Sprite::LoadFromTexture( RageTextureID ID )
|
|||||||
Sprite::m_size.x = (float)m_pTexture->GetSourceFrameWidth();
|
Sprite::m_size.x = (float)m_pTexture->GetSourceFrameWidth();
|
||||||
Sprite::m_size.y = (float)m_pTexture->GetSourceFrameHeight();
|
Sprite::m_size.y = (float)m_pTexture->GetSourceFrameHeight();
|
||||||
|
|
||||||
|
// apply clipping (if any)
|
||||||
|
if( m_fRememberedClipWidth != -1 && m_fRememberedClipHeight != -1 )
|
||||||
|
ScaleToClipped( m_fRememberedClipWidth, m_fRememberedClipHeight );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sprite::LoadStatesFromTexture()
|
||||||
|
{
|
||||||
// Assume the frames of this animation play in sequential order with 0.1 second delay.
|
// Assume the frames of this animation play in sequential order with 0.1 second delay.
|
||||||
m_States.clear();
|
m_States.clear();
|
||||||
|
|
||||||
|
if( m_pTexture == NULL )
|
||||||
|
{
|
||||||
|
State newState;
|
||||||
|
newState.fDelay = 0.1f;
|
||||||
|
newState.rect = RectF( 0, 0, 1, 1 );
|
||||||
|
m_States.push_back( newState );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for( int i=0; i<m_pTexture->GetNumFrames(); ++i )
|
for( int i=0; i<m_pTexture->GetNumFrames(); ++i )
|
||||||
{
|
{
|
||||||
State newState;
|
State newState;
|
||||||
@@ -284,10 +305,6 @@ void Sprite::LoadFromTexture( RageTextureID ID )
|
|||||||
newState.rect = *m_pTexture->GetTextureCoordRect( i );
|
newState.rect = *m_pTexture->GetTextureCoordRect( i );
|
||||||
m_States.push_back( newState );
|
m_States.push_back( newState );
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply clipping (if any)
|
|
||||||
if( m_fRememberedClipWidth != -1 && m_fRememberedClipHeight != -1 )
|
|
||||||
ScaleToClipped( m_fRememberedClipWidth, m_fRememberedClipHeight );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::UpdateAnimationState()
|
void Sprite::UpdateAnimationState()
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void LoadFromTexture( RageTextureID ID );
|
void LoadFromTexture( RageTextureID ID );
|
||||||
|
void LoadStatesFromTexture();
|
||||||
|
|
||||||
void DrawTexture( const TweenState *state );
|
void DrawTexture( const TweenState *state );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user