You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
#include "coreSprite.h"
|
|
#include "../gui_sdl.h"
|
|
|
|
sdlSprite::sdlSprite(int x, int y, int width, int height, char *textureFile):sdlGraphicElement( x, y, width, height){
|
|
m_pTexItem = NULL;
|
|
sprintf(m_sTextureName, "%s", textureFile);
|
|
m_pGUI->registerGEL(this);
|
|
};
|
|
sdlSprite::sdlSprite(SDL_Rect& R, char* textureFile) :sdlGraphicElement(R) {
|
|
m_pTexItem = NULL;
|
|
sprintf(m_sTextureName, "%s", textureFile);
|
|
m_pGUI->registerGEL(this);
|
|
};
|
|
sdlSprite::sdlSprite(SDL_Rect* R, char* textureFile) :sdlGraphicElement(R) {
|
|
m_pTexItem = NULL;
|
|
sprintf( m_sTextureName, "%s", textureFile );
|
|
m_pGUI->registerGEL(this);
|
|
};
|
|
|
|
sdlSprite::~sdlSprite(){
|
|
m_pGUI->removeGEL(this);
|
|
};
|
|
|
|
bool sdlSprite::create(void) {
|
|
if (sdlGraphicElement::create()) return true;
|
|
if (m_pGUI != NULL) {
|
|
m_pTexItem = m_pGUI->loadTexture(m_sTextureName);
|
|
if (m_pTexItem != NULL) {
|
|
m_bInitComplete = true;
|
|
} else {
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "CreateTextureFromSurface failed : % s", SDL_GetError());
|
|
};
|
|
};
|
|
return m_bInitComplete;
|
|
};
|
|
|
|
void sdlSprite::draw(SDL_Renderer* tPtr) {
|
|
if (!m_bInitComplete)return;
|
|
if (tPtr == NULL)return;
|
|
|
|
};
|