SDLPP: add function to change texture while keeping SRC rect

This commit is contained in:
zv0n 2021-07-23 00:05:40 +02:00
parent 0e71dfa7d5
commit 79d9f266b4
2 changed files with 4 additions and 0 deletions

View File

@ -78,6 +78,9 @@ void RenderObject::setTexture( const std::shared_ptr< Texture > &t,
texture = t; texture = t;
src_rect = source_rect; src_rect = source_rect;
} }
void RenderObject::setTextureKeepSRC( const std::shared_ptr< Texture > &t ) {
setTexture(t, src_rect);
}
void RenderObject::setTexture( const std::shared_ptr< Texture > &t, void RenderObject::setTexture( const std::shared_ptr< Texture > &t,
int source_x, int source_y, int source_width, int source_x, int source_y, int source_width,
int source_height ) { int source_height ) {

View File

@ -63,6 +63,7 @@ public:
bool hasCollisions() const; bool hasCollisions() const;
const std::vector< std::shared_ptr< CollisionPolygon > > & const std::vector< std::shared_ptr< CollisionPolygon > > &
getCollisions() const; getCollisions() const;
virtual void setTextureKeepSRC( const std::shared_ptr< Texture > &t );
virtual void setTexture( const std::shared_ptr< Texture > &t, int source_x, virtual void setTexture( const std::shared_ptr< Texture > &t, int source_x,
int source_y, int source_width, int source_y, int source_width,
int source_height ); int source_height );