Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
Loading...
Searching...
No Matches
ShapeSprite Class Reference

#include <definitions.hpp>

Inheritance diagram for ShapeSprite:
Component

Public Member Functions

 ShapeSprite ()
 
 ShapeSprite (const std::shared_ptr< Shape > &shape)
 
void render (std::shared_ptr< Window > window) override
 
template<class Archive >
void save (Archive &ar) const
 
template<class Archive >
void load (Archive &ar)
 
- Public Member Functions inherited from Component
virtual ~Component ()=default
 
virtual void update (float deltaTime)
 
virtual void initialize ()
 
virtual void physicsUpdate ()
 
virtual void input (InputEvent &event)
 
virtual void postLoad ()
 
virtual void exit ()
 
NodegetNode () const
 
void setNode (Node *n)
 
template<class Archive >
void save (Archive &ar) const
 
template<class Archive >
void load (Archive &ar)
 

Public Attributes

Vector2 origin = {0.5f, 0.5f}
 
std::shared_ptr< Shapeshape
 
bool visible = true
 
bool screenSpace = false
 
Color modulate = Color::WHITE
 

Detailed Description

ShapeSprite

A dynamic sprite (mainly used for debugging) which can draw solid color filled shapes.

Example usage:

std::shared_ptr<Node> spriteNode = std::make_shared<Node>();
auto boxShape = std::make_shared<BoxShape>(Vector2{0.5f, 0.5f});
std::shared_ptr<ShapeSprite> sprite = std::make_shared<ShapeSprite>(shape);
spriteNode->addComponent(sprite);
std::shared_ptr< Shape > shape
Definition definitions.hpp:259
Definition definitions.hpp:77

Properties and usages

You can make ShapeSprites render using screen space positioning. This can be used for UI elements and things like that:

sprite->screenSpace = true; // Now, the position of the sprite will directly translate to screen coordinates!

Also, you can modify the modulate variable of the sprite to change its color:

sprite->color = Color::RED;
static const Color RED
Definition definitions.hpp:60

Constructor & Destructor Documentation

◆ ShapeSprite() [1/2]

ShapeSprite::ShapeSprite ( )
default

◆ ShapeSprite() [2/2]

ShapeSprite::ShapeSprite ( const std::shared_ptr< Shape > &  shape)
explicit

Member Function Documentation

◆ load()

template<class Archive >
void ShapeSprite::load ( Archive &  ar)
inline

◆ render()

void ShapeSprite::render ( std::shared_ptr< Window window)
overridevirtual

Reimplemented from Component.

◆ save()

template<class Archive >
void ShapeSprite::save ( Archive &  ar) const
inline

Member Data Documentation

◆ modulate

Color ShapeSprite::modulate = Color::WHITE

◆ origin

Vector2 ShapeSprite::origin = {0.5f, 0.5f}

◆ screenSpace

bool ShapeSprite::screenSpace = false

◆ shape

std::shared_ptr<Shape> ShapeSprite::shape

◆ visible

bool ShapeSprite::visible = true

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