Files
itgmania212121/stepmania/src/Sprite.h
T

85 lines
2.4 KiB
C++
Raw Normal View History

#ifndef SPRITE_H
#define SPRITE_H
/*
-----------------------------------------------------------------------------
File: Sprite.h
Desc: A bitmap Actor that animates and moves around.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-06-27 17:49:10 +00:00
Chris Danford
-----------------------------------------------------------------------------
*/
2001-11-03 10:52:42 +00:00
#include "Actor.h"
#include "RageUtil.h"
#include "RageTexture.h"
#define MAX_SPRITE_STATES 256
class Sprite: public Actor
{
public:
Sprite();
virtual ~Sprite();
virtual bool Load( CString sFilePath ) { return Load( sFilePath, RageTexturePrefs() ); }
virtual bool Load( CString sFilePath, RageTexturePrefs prefs )
2002-01-16 10:01:32 +00:00
{
2002-03-31 07:55:25 +00:00
ASSERT( sFilePath != "" );
2002-01-16 10:01:32 +00:00
if( sFilePath.Right(7) == ".sprite" )
return LoadFromSpriteFile( sFilePath, prefs );
2002-01-16 10:01:32 +00:00
else
return LoadFromTexture( sFilePath, prefs );
2002-01-16 10:01:32 +00:00
};
2002-04-16 17:31:00 +00:00
void UnloadTexture();
2002-04-28 20:42:32 +00:00
RageTexture* GetTexture() { return m_pTexture; };
2001-11-03 10:52:42 +00:00
2002-05-19 01:59:48 +00:00
virtual void DrawPrimitives();
virtual void Update( float fDeltaTime );
2001-11-03 10:52:42 +00:00
2002-12-17 10:39:33 +00:00
virtual void StartAnimating() { m_bIsAnimating = true; if(m_pTexture) m_pTexture->Play(); };
virtual void StopAnimating() { m_bIsAnimating = false; if(m_pTexture) m_pTexture->Pause(); };
virtual void SetState( int iNewState );
2001-11-03 10:52:42 +00:00
int GetNumStates() { return m_iNumStates; };
2001-11-03 10:52:42 +00:00
CString GetTexturePath() { return m_sTexturePath; };
2002-10-31 06:00:30 +00:00
void SetCustomTextureRect( const RectF &new_texcoord_frect );
2002-01-29 21:56:14 +00:00
void SetCustomTextureCoords( float fTexCoords[8] );
2002-06-27 17:49:10 +00:00
void GetCustomTextureCoords( float fTexCoordsOut[8] );
2002-10-31 06:00:30 +00:00
void SetCustomSourceRect( const RectF &rectSourceCoords ); // in source pixel space
void SetCustomImageRect( RectF rectImageCoords ); // in image pixel space
2002-01-29 21:56:14 +00:00
void SetCustomImageCoords( float fImageCoords[8] );
2002-03-31 07:55:25 +00:00
void StopUsingCustomCoords();
2001-11-03 10:52:42 +00:00
protected:
virtual bool LoadFromTexture( CString sTexturePath, RageTexturePrefs prefs );
virtual bool LoadFromSpriteFile( CString sSpritePath, RageTexturePrefs prefs );
2002-01-16 10:01:32 +00:00
2001-11-03 10:52:42 +00:00
CString m_sSpritePath;
2002-01-16 10:01:32 +00:00
RageTexture* m_pTexture;
bool m_bDrawIfTextureNull;
2001-11-03 10:52:42 +00:00
CString m_sTexturePath;
int m_iStateToFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames
2001-11-28 20:26:45 +00:00
float m_fDelay[MAX_SPRITE_STATES];
int m_iNumStates;
int m_iCurState;
2001-11-28 20:26:45 +00:00
bool m_bIsAnimating;
float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
2001-11-03 10:52:42 +00:00
2001-12-28 10:15:59 +00:00
bool m_bUsingCustomTexCoords;
//FRECT m_CustomTexCoordRect;
float m_CustomTexCoords[8]; // (x,y) * 4
2001-11-03 10:52:42 +00:00
};
#endif