SDLPP: Scene - add function to bring objet to the front or back of Z

This commit is contained in:
zv0n 2021-04-25 15:54:16 +02:00
parent 1f5e3a999c
commit 5b96de0d9d
2 changed files with 8 additions and 0 deletions

View File

@ -59,6 +59,12 @@ void Scene::moveZ( const std::shared_ptr< RenderObject > &obj, int addition ) {
std::iter_swap( render_objects.begin() + original_index, std::iter_swap( render_objects.begin() + original_index,
render_objects.begin() + original_index + addition ); render_objects.begin() + original_index + addition );
} }
void Scene::moveZTop( const std::shared_ptr< RenderObject > &obj ) {
setZIndex( obj, render_objects.size() - 1 );
}
void Scene::moveZBottom( const std::shared_ptr< RenderObject > &obj ) {
setZIndex( obj, 0 );
}
std::shared_ptr< RenderObject > Scene::getObject( int index ) { std::shared_ptr< RenderObject > Scene::getObject( int index ) {
return render_objects[index]; return render_objects[index];
} }

View File

@ -19,6 +19,8 @@ public:
void moveDownZ( const std::shared_ptr< RenderObject > &obj ); void moveDownZ( const std::shared_ptr< RenderObject > &obj );
void moveUpZ( const std::shared_ptr< RenderObject > &obj ); void moveUpZ( const std::shared_ptr< RenderObject > &obj );
void moveZ( const std::shared_ptr< RenderObject > &obj, int addition ); void moveZ( const std::shared_ptr< RenderObject > &obj, int addition );
void moveZTop( const std::shared_ptr< RenderObject > &obj );
void moveZBottom( const std::shared_ptr< RenderObject > &obj );
std::shared_ptr< RenderObject > getObject( int index ); std::shared_ptr< RenderObject > getObject( int index );
std::vector< std::shared_ptr< RenderObject > > getObjects(); std::vector< std::shared_ptr< RenderObject > > getObjects();
std::vector< std::shared_ptr< RenderObject > > std::vector< std::shared_ptr< RenderObject > >