![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <physics.hpp>
Public Member Functions | |
| StaticBody () | |
| StaticBody (const std::shared_ptr< Shape > &shape) | |
| void | physicsUpdate () override |
| void | initCompute () override |
| void | setPosition (Vector2 pos) const |
| void | setAngle (float angle) const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Member Functions inherited from PhysicsBody | |
| void | exit () override |
| void | initialize () override |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
| b2BodyId | getBodyId () |
| b2ShapeId | getShapeId () |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | update (float deltaTime) |
| virtual void | render (std::shared_ptr< Window > window) |
| virtual void | input (InputEvent &event) |
| virtual void | postLoad () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Additional Inherited Members | |
Public Attributes inherited from PhysicsBody | |
| Signal< PhysicsBody * > | collisionEnter |
| Signal< PhysicsBody * > | collisionExit |
| Signal< PhysicsBody * > | collisionHit |
| Signal | mouseEntered |
| Signal | mouseExited |
| std::shared_ptr< Shape > | shape |
Protected Attributes inherited from PhysicsBody | |
| bool | sensor |
| b2BodyDef | bodyDef |
| b2BodyId | bodyId |
| b2ShapeId | shapeId |
| Transform | storedTransform |
The StaticBody component is a type of PhysicsBody. The main difference between StaticBody and any other physics bodies is that it does not move, at all, unless it is moved by the user.
Like any other physics body, once it is attached to a node, you must not move the node through its transform property but through the setPosition() and setAngle() functions of the physics body.
Example usage:
For more insight regarding anything physics related, the physics example and node tree example also utilize staticbodies!
| StaticBody::StaticBody | ( | ) |
| StaticBody::StaticBody | ( | const std::shared_ptr< Shape > & | shape | ) |
|
overridevirtual |
Reimplemented from PhysicsBody.
|
inline |
|
overridevirtual |
Implements PhysicsBody.
|
inline |
| void StaticBody::setAngle | ( | float | angle | ) | const |
| void StaticBody::setPosition | ( | Vector2 | pos | ) | const |