Added source rectangle option for texture setting

This commit is contained in:
2021-03-07 13:06:08 +01:00
parent fa10620901
commit fbc1fdd6f7
4 changed files with 82 additions and 14 deletions
+12 -2
View File
@@ -42,8 +42,16 @@ public:
bool hasCollisions() const;
const std::vector< std::shared_ptr< CollisionPolygon > > &
getCollisions() const;
virtual void setTexture( const std::shared_ptr< Texture > &t );
virtual void setTexture( const std::string &img_path );
virtual void setTexture( const std::shared_ptr< Texture > &t, int source_x,
int source_y, int source_width,
int source_height );
virtual void setTexture( const std::shared_ptr< Texture > &t,
SDL_Rect source_rect = { -1, -1, -1, -1 } );
virtual void setTexture( const std::string &img_path, int source_x,
int source_y, int source_width,
int source_height );
virtual void setTexture( const std::string &img_path,
SDL_Rect source_rect = { -1, -1, -1, -1 } );
virtual void setTexture( Font &font, const std::string &text,
const std::string &color = "FFFFFF",
const std::string &outline_color = "000000",
@@ -81,6 +89,7 @@ public:
protected:
virtual void copyTo( std::shared_ptr< RenderObject > other );
bool entireTexture();
std::vector< std::shared_ptr< CollisionPolygon > > collisions;
std::shared_ptr< Texture > texture;
std::shared_ptr< Texture > cur_texture;
@@ -98,6 +107,7 @@ protected:
bool is_static = true;
bool centerx = false;
SDL_Rect rect;
SDL_Rect src_rect = { -1, -1, -1, -1 };
private:
void setSceneID( int id );