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:
Inheritance graph
[legend]
Collaboration diagram for SpriteComponent:
Collaboration graph
[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
 
TransformComponenttransform
 
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
transformthe 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 ( )
inlineoverridevirtual

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
filePaththe path to the imagefile (must be .bmp currently)
renthe renderer to be drawn to
wthe width of the Sprite
hthe height of the Sprite
frameshow many frames are on the spritesheet
targetDisplayhow 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)
overridevirtual

Render the Sprite.

Parameters
renthe SDL_Renderer to draw the sprite to

Reimplemented from Component.

◆ ShowComponentEditor()

void SpriteComponent::ShowComponentEditor ( bool *  showEditor)
overridevirtual

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 
)
overridevirtual

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

Parameters
eany inputs given by the user
framewhat frame is the game currently displaying
broadcastLista 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: