A class wrapper to ease the instantiation and use of Box2D kinematic bodies. It also performs conversions between meters in physics space and pixels in screen space automatically.
More...
#include <KinematicBody.hpp>
A class wrapper to ease the instantiation and use of Box2D kinematic bodies. It also performs conversions between meters in physics space and pixels in screen space automatically.
◆ KinematicBody() [1/2]
pk::KinematicBody::KinematicBody |
( |
| ) |
|
|
inlineprivate |
Default constructor - Inaccessible.
◆ KinematicBody() [2/2]
pk::KinematicBody::KinematicBody |
( |
b2World * |
world, |
|
|
GLRect |
rect |
|
) |
| |
◆ ~KinematicBody()
virtual pk::KinematicBody::~KinematicBody |
( |
| ) |
|
|
virtual |
◆ allowSleep()
void pk::KinematicBody::allowSleep |
( |
bool |
s | ) |
|
|
inline |
Set the body to allow sleeping. This increases efficiency and performance of Box2D while also preventing bodies from randomly jittering when they should appear still.
- Parameters
-
bool | s - a plain old bool. |
◆ destroyBody()
void pk::KinematicBody::destroyBody |
( |
| ) |
|
|
inline |
Destroy the KinematicBody. Safely removes the body using Box2D internals.
◆ getDensity()
float pk::KinematicBody::getDensity |
( |
| ) |
|
|
inline |
Get the density of the body.
- Returns
- float - a plain old float.
◆ getFriction()
float pk::KinematicBody::getFriction |
( |
| ) |
|
|
inline |
Get the friction of the body.
- Returns
- float - a plain old float.
◆ getLinearVelocity()
glm::vec2 pk::KinematicBody::getLinearVelocity |
( |
| ) |
|
|
inline |
Get the linear velocity of the body.
- Returns
- glm::vec2 - a vector of floats.
◆ getPosition()
glm::vec2 pk::KinematicBody::getPosition |
( |
| ) |
|
|
inline |
Get the position of the body in Box2D units (meters).
- Returns
- b2Vec2 - a Box2D vector of floats.
◆ getPositionInPixels()
glm::vec2 pk::KinematicBody::getPositionInPixels |
( |
| ) |
|
|
inline |
Get the position of the body in screen units (pixels).
- Returns
- glm::vec2 - a vector of floats.
◆ getRestitution()
float pk::KinematicBody::getRestitution |
( |
| ) |
|
|
inline |
Get the restitution of the body.
- Returns
- float - a plain old float.
◆ getRotation()
float pk::KinematicBody::getRotation |
( |
| ) |
|
|
inline |
Get the rotation of the KinematicBody.
- Returns
- float - the rotation given as a float in degrees.
◆ getWorld()
b2World * pk::KinematicBody::getWorld |
( |
| ) |
|
|
inline |
Get a pointer to the Box2D world the static platform is tied to.
◆ setDensity()
void pk::KinematicBody::setDensity |
( |
float |
density | ) |
|
|
inline |
Set the density of the body.
- Parameters
-
float | density - a plain old float. |
◆ setFixedRotation()
void pk::KinematicBody::setFixedRotation |
( |
bool |
r | ) |
|
|
inline |
Set the body's rotation as fixed (no rotation).
- Parameters
-
bool | r - a plain old bool. |
◆ setFriction()
void pk::KinematicBody::setFriction |
( |
float |
friction | ) |
|
|
inline |
Set the friction for the body.
- Parameters
-
float | friction - a plain old float. |
◆ setLinearVelocity()
void pk::KinematicBody::setLinearVelocity |
( |
glm::vec2 |
v | ) |
|
|
inline |
Set the linear velocity of the body.
- Parameters
-
glm::vec2 | v - a vector of floats. |
◆ setPosition()
void pk::KinematicBody::setPosition |
( |
glm::vec2 |
position | ) |
|
|
inline |
Set the position of the KinematicBody.
- Parameters
-
glm::vec2 | position - the position given as a glm::vec2 of floats. |
◆ setRestitution()
void pk::KinematicBody::setRestitution |
( |
float |
restitution | ) |
|
|
inline |
Set the restitution (bounciness) for the body.
- Parameters
-
float | restitution - a plain old float. |
◆ setTransform()
void pk::KinematicBody::setTransform |
( |
b2Vec2 |
position, |
|
|
float |
angle |
|
) |
| |
|
inline |
Set the transform (position and angle) of the KinematicBody.
- Parameters
-
b2Vec2 | position - the position given as a b2Vec2 of floats. |
float | angle - the angle given as a float in degrees. |
◆ m_body
b2Body* pk::KinematicBody::m_body |
|
private |
◆ m_bodyDef
b2BodyDef pk::KinematicBody::m_bodyDef |
|
private |
A Box2D body definition structure.
◆ m_fixtureDef
b2FixtureDef pk::KinematicBody::m_fixtureDef |
|
private |
A Box2D fixture definition structure.
◆ m_rect
GLRect pk::KinematicBody::m_rect |
|
private |
◆ m_shape
b2PolygonShape pk::KinematicBody::m_shape |
|
private |
◆ m_world
b2World* pk::KinematicBody::m_world |
|
private |
A pointer to the Box2D world.
The documentation for this class was generated from the following file: