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

#include <definitions.hpp>

Inheritance diagram for Shape:
BoxShape CapsuleShape CircleShape PolygonShape SegmentShape

Public Member Functions

virtual ~Shape ()=default
 
void applyMaterial (const Material &material)
 
ShapesetSensor (bool sensor)
 
template<class Archive >
void save (Archive &ar) const
 
template<class Archive >
void load (Archive &ar)
 

Public Attributes

b2ShapeDef shapeDef
 
Vector2 origin
 

Protected Member Functions

void postLoad ()
 

Detailed Description

Shape

The base Shape class defines properties which are inherited by all Shapes, such as BoxShape, CircleShape, CapsuleShape and PolygonShape.

This class has two notable properties:

shape->origin = {0.5f, 0.5f}; // The origin of the shape. This is disabled for PolygonShape.
shape->applyMaterial(myMaterial); // This is the main method of applying materials to shapes.

You can also set a shape to be a sensor, which means that it will not cause physical collisions but will still trigger collision events and mouse hover events:

shape->setSensor(true);

For more insight regarding sensors, the button example utilizes sensors for its buttons!

Constructor & Destructor Documentation

◆ ~Shape()

virtual Shape::~Shape ( )
virtualdefault

Member Function Documentation

◆ applyMaterial()

void Shape::applyMaterial ( const Material material)

◆ load()

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

◆ postLoad()

void Shape::postLoad ( )
inlineprotected

◆ save()

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

◆ setSensor()

Shape * Shape::setSensor ( bool  sensor)
inline

Member Data Documentation

◆ origin

Vector2 Shape::origin

◆ shapeDef

b2ShapeDef Shape::shapeDef

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