Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
rune::Sprite Class Reference

A sprite that can be given a texture and animated. More...

#include <sprite.h>

Inheritance diagram for rune::Sprite:
Collaboration diagram for rune::Sprite:

Public Member Functions

 Sprite ()
 Default empty constructor for generating a sprite, uses default shader.
 
 Sprite (std::string const &spriteLocation, unsigned int drawMode=LINEAR_FILTER)
 Default constructor for generating a sprite from a PNG file, uses default shader. More...
 
virtual void awake () override
 Virtual awake method being overloaded.
 
virtual void start () override
 Virtual start method being overloaded.
 
void setUpBuffers (void)
 Initialize opengl for the sprite.
 
virtual void draw (rune::RenderWindow &)
 Draw overload so that sprite can be displayed to the screen. More...
 
void setTexture (std::string const &texture, unsigned int drawMode=LINEAR_FILTER)
 Set the texture of the sprite. More...
 
void setTexture (Texture *texture)
 Set the texture based off another already loaded texture. More...
 
void setTextureRect (int xPos, int yPos, int width, int height)
 Set the area of the texture to be rendered. More...
 
IntRect getTextureRect (void)
 Return the rectangle. More...
 
unsigned int getDrawMode ()
 Returns the filtering mode of the sprite. More...
 
void setMirror (bool mirror)
 Sets whether or not the sprite should be drawn in reverse.
 
bool getMirror (void)
 Gets whether or not the sprite should be drawn in reverse. More...
 
- Public Member Functions inherited from rune::Component
 Component ()=default
 Default constructor to set up.
 
virtual void update ()
 A function for each component that is called every frame.
 
virtual void fixedUpdate ()
 A function for each component that is called once every physics update.
 
void setParent (GameObject *newParent)
 A function to set the pointer to the parent rune::GameObject for each component. More...
 
void setEnable (bool newEnable)
 Enable or disable the component. More...
 
bool isComponentEnabled (void)
 Gets whether or not the current component is enabled.
 
void onNotify (Signal const &signal) override
 A virtual method to be overridden by a concrete implementation of the observer class.
 

Public Attributes

Shader objectShader
 The Shader that should be used to draw the sprite.
 
Color spriteColor
 The Color of the sprite for drawing purposes.
 

Additional Inherited Members

- Protected Attributes inherited from rune::Component
GameObjectparentObject = nullptr
 The rune::GameObject that this component is attached to. If not attached to a rune::GameObject this will equal nullptr.
 
bool isEnabled = true
 Whether or not the component is currently enabled. If not enabled, update function will not be called.
 

Detailed Description

A sprite that can be given a texture and animated.

Author
Thomas Montano
Date
April 27 2020

Constructor & Destructor Documentation

◆ Sprite()

rune::Sprite::Sprite ( std::string const &  spriteLocation,
unsigned int  drawMode = LINEAR_FILTER 
)

Default constructor for generating a sprite from a PNG file, uses default shader.

Parameters
spriteLocationA filepath for the sprite png file to be drawn.
drawModeHow would you like the sprite to be filtered when drawn.
Warning
Use NEAREST_FILTER for pixel art sprites. LINEAR_FILTER is used by default.

Member Function Documentation

◆ draw()

void rune::Sprite::draw ( rune::RenderWindow window)
virtual

Draw overload so that sprite can be displayed to the screen.

Parameters
windowThe window that the sprite is being drawn to.

Implements rune::Drawable.

◆ getDrawMode()

unsigned int rune::Sprite::getDrawMode ( )

Returns the filtering mode of the sprite.

Returns
The draw mode currently being used to render this sprite.

◆ getMirror()

bool rune::Sprite::getMirror ( void  )

Gets whether or not the sprite should be drawn in reverse.

Returns
Whether or not the sprite is currently being mirrored.

◆ getTextureRect()

rune::IntRect rune::Sprite::getTextureRect ( void  )

Return the rectangle.

Returns
The rune::IntRect currently applied to this sprite.

◆ setTexture() [1/2]

void rune::Sprite::setTexture ( std::string const &  texture,
unsigned int  drawMode = LINEAR_FILTER 
)

Set the texture of the sprite.

Parameters
textureThe file path to the texture that is to be loaded onto the sprite.
drawModeHow would you like the sprite to be filtered when drawn.

◆ setTexture() [2/2]

void rune::Sprite::setTexture ( Texture texture)

Set the texture based off another already loaded texture.

Parameters
textureThe texture that should be given to this sprite for drawing.

◆ setTextureRect()

void rune::Sprite::setTextureRect ( int  xPos,
int  yPos,
int  width,
int  height 
)

Set the area of the texture to be rendered.

Parameters
xPosThe left most x position of the texture to be used.
yPosThe top most y position of the texture to be used.
widthThe width of the texture.
heightThe height of the texture.

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