Jagguar Game Engine

Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SpriteComponent Class Reference

`#include <Sprite.hpp>`

Inheritance diagram for SpriteComponent:
[legend]
Collaboration diagram for SpriteComponent:
[legend]

## Public Member Functions
| SpriteComponent (TransformComponent *transform)
| ~SpriteComponent ()
void | LoadImage (std::string filePath, SDL_Renderer *ren, int w, int h, int frames, Vec2D targetDisplay)
Vec2D | getDimensions ()
void | Update (SDL_Event e, int frame, std::vector< std::string > broadcastList) override
void | Render (SDL_Renderer *ren) override
void | ShowComponentEditor (bool *showEditor) override
const char * | ComponentTypeName () override
Public Member Functions inherited from Component
| Component ()
| ~Component ()
virtual void | Update (SDL_Event e, int frame, std::vector< std::string > broadcastList)
virtual void | Render (SDL_Renderer *ren)
virtual void | ShowComponentEditor (bool *showEditor)
virtual bool | HasTag (ComponentTag t)
virtual const char * | ComponentTypeName ()
void | ParseAndUpdateBroadcast (std::vector< std::string > broadcastList)

## Private Attributes
unsigned int | mCurrentFrame {0}
unsigned int | mLastFrame {7}
SDL_Surface * | mSpriteSheet = nullptr
SDL_Texture * | mTexture = nullptr
SDL_Rect | mSrc
SDL_Rect | mDest
int | width
int | height
int | frameCount
Vec2D | dimensions
TransformComponent * | transform
SDL_Renderer * | last_used = nullptr

## Additional Inherited Members
Protected Attributes inherited from Component
std::vector< ComponentTag > | tags
std::vector< std::string > | previousBroadcasts
std::vector< std::string > | pendingBroadcasts

## Detailed Description

A Component implementation to load and display sprites.

## Constructor & Destructor Documentation

## ◆ SpriteComponent()

SpriteComponent::SpriteComponent | ( | TransformComponent * | transform | ) |

Construct a new Sprite Component object

Parameters

  transform | the position of the parent GameObject

Here is the call graph for this function:

## ◆ ~SpriteComponent()

SpriteComponent::~SpriteComponent | ( |  | ) |

Destroy the Sprite Component object

## Member Function Documentation

## ◆ ComponentTypeName()

const char * SpriteComponent::ComponentTypeName | ( |  | ) |
| inline override virtual

The name of the component type. Used by the GUI

See also
  GameMakerGUI::CreateComponent()

Returns
  the name of the component

Reimplemented from Component.

## ◆ getDimensions()

Vec2D SpriteComponent::getDimensions | ( |  | ) |

Get the dimensions of the Sprite.

Returns
  the dimensions of the Sprite

## ◆ LoadImage()

void SpriteComponent::LoadImage | ( | std::string | filePath,
|  | SDL_Renderer * | ren,
|  | int | w,
|  | int | h,
|  | int | frames,
|  | Vec2D | targetDisplay
| ) |  |

Load a new image to be displayed.

Parameters

  filePath | the path to the imagefile (must be .bmp currently)
  ren | the renderer to be drawn to
  w | the width of the Sprite
  h | the height of the Sprite
  frames | how many frames are on the spritesheet
  targetDisplay | how big the displayed sprite is

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ Render()

void SpriteComponent::Render | ( | SDL_Renderer * | ren | ) |
| override virtual

Render the Sprite.

Parameters

  ren | the SDL_Renderer to draw the sprite to

Reimplemented from Component.

## ◆ ShowComponentEditor()

void SpriteComponent::ShowComponentEditor | ( | bool * | showEditor | ) |
| override virtual

Using Imgui, render an editor for this component

See also
  GameMakerGUI::RenderEditor()

Parameters

  showEditor |

Reimplemented from Component.

Here is the call graph for this function:

## ◆ Update()

void SpriteComponent::Update | ( | SDL_Event | e,
|  | int | frame,
|  | std::vector< std::string > | broadcastList
| ) |  |
| override virtual

Animate the Sprite based on the frame given. Updates the state of the component object. Called by the Engine every tick

Parameters

  e | any inputs given by the user
  frame | what frame is the game currently displaying
  broadcastList | a list to be used to send messages between components

See also
  ParseAndUpdateBroadcast()

Reimplemented from Component.

Here is the call graph for this function:

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

- include/Sprite.hpp
- src/Sprite.cpp