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.

40 lines
1.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "coreSprite.h"
  2. #include "../gui_sdl.h"
  3. sdlSprite::sdlSprite(int x, int y, int width, int height, char *textureFile):sdlGraphicElement( x, y, width, height){
  4. m_pTexItem = NULL;
  5. sprintf(m_sTextureName, "%s", textureFile);
  6. m_pGUI->registerGEL(this);
  7. };
  8. sdlSprite::sdlSprite(SDL_Rect& R, char* textureFile) :sdlGraphicElement(R) {
  9. m_pTexItem = NULL;
  10. sprintf(m_sTextureName, "%s", textureFile);
  11. m_pGUI->registerGEL(this);
  12. };
  13. sdlSprite::sdlSprite(SDL_Rect* R, char* textureFile) :sdlGraphicElement(R) {
  14. m_pTexItem = NULL;
  15. sprintf( m_sTextureName, "%s", textureFile );
  16. m_pGUI->registerGEL(this);
  17. };
  18. sdlSprite::~sdlSprite(){
  19. m_pGUI->removeGEL(this);
  20. };
  21. bool sdlSprite::create(void) {
  22. if (sdlGraphicElement::create()) return true;
  23. if (m_pGUI != NULL) {
  24. m_pTexItem = m_pGUI->loadTexture(m_sTextureName);
  25. if (m_pTexItem != NULL) {
  26. m_bInitComplete = true;
  27. } else {
  28. SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "CreateTextureFromSurface failed : % s", SDL_GetError());
  29. };
  30. };
  31. return m_bInitComplete;
  32. };
  33. void sdlSprite::draw(SDL_Renderer* tPtr) {
  34. if (!m_bInitComplete)return;
  35. if (tPtr == NULL)return;
  36. };