Simple C++ Game
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
RenderComponent Class Reference

A component that stores the information required to render the entity on the screen. More...

#include <Components.hpp>

Inheritance diagram for RenderComponent:
Inheritance graph
[legend]
Collaboration diagram for RenderComponent:
Collaboration graph
[legend]

Public Member Functions

 RenderComponent ()
 Construct a new RenderComponent. More...
 
- Public Member Functions inherited from Entity::Component
 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.
 

Detailed Description

A component that stores the information required to render the entity on the screen.

Constructor & Destructor Documentation

◆ RenderComponent()

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.

Member Data Documentation

◆ 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.


The documentation for this class was generated from the following file: