Simple C++ Game
|
A component that stores the information required to render the entity on the screen. More...
#include <Components.hpp>
Public Member Functions | |
RenderComponent () | |
Construct a new RenderComponent. More... | |
![]() | |
Component (const std::string id) | |
Construct a new Component object. More... | |
virtual | ~Component () |
This is only declared to make the class polymorphic so that dymaic_cast between Component types works. | |
const std::string | getId () const |
Get the ID of the component. This will return the same value for all instances of a class of Component. | |
Public Attributes | |
std::shared_ptr< sf::Texture > | texture |
The texture that the sprite uses. More... | |
sf::Sprite | sprite |
The sprite that will be rendered to represent the entity. | |
Static Public Attributes | |
static const std::string | RENDER_COMP_ID |
The ID of RenderComponent. | |
A component that stores the information required to render the entity on the screen.
RenderComponent::RenderComponent | ( | ) |
Construct a new RenderComponent.
Construct a new RenderComponent with unitialized variables. After creating a RenderComponent this way, you should load the texture (such as with texture.loadFromFile() ) and then set the sprite to a new sprite based on that texture.
std::shared_ptr<sf::Texture> RenderComponent::texture |
The texture that the sprite uses.
The sprite does not use a pointer that keeps ownership of the texture, so we do so here to ensure it doesn't go out of scope.