A class representing a Box2D dynamic body with special fixtures and data used to track collisions and respond to them in a way that is appropriate to the game rather than what is correct for the physical simulation.
More...
#include <CharacterBody.hpp>
A class representing a Box2D dynamic body with special fixtures and data used to track collisions and respond to them in a way that is appropriate to the game rather than what is correct for the physical simulation.
◆ CharacterBody() [1/2]
pk::CharacterBody::CharacterBody |
( |
| ) |
|
|
inlineprivate |
Default constructor - Inaccessible.
◆ CharacterBody() [2/2]
pk::CharacterBody::CharacterBody |
( |
b2World * |
world, |
|
|
GLRect |
rect, |
|
|
int |
id |
|
) |
| |
◆ ~CharacterBody()
virtual pk::CharacterBody::~CharacterBody |
( |
| ) |
|
|
virtual |
◆ allowSleep()
void pk::CharacterBody::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. |
◆ canJump()
bool pk::CharacterBody::canJump |
( |
| ) |
|
◆ destroyBody()
void pk::CharacterBody::destroyBody |
( |
| ) |
|
Destroy the CharacterBody. Safe destruction using the internals of Box2D.
◆ footSensor()
Get the foot sensor data.
- Returns
- SensorData* - a pointer to the foot sensor data.
◆ getCharacterBodyID()
int pk::CharacterBody::getCharacterBodyID |
( |
| ) |
|
|
inline |
◆ getDensity()
float pk::CharacterBody::getDensity |
( |
| ) |
|
|
inline |
Get the density of the body.
- Returns
- float - a plain old float.
◆ getFriction()
float pk::CharacterBody::getFriction |
( |
| ) |
|
|
inline |
Get the friction of the body.
- Returns
- float - a plain old float.
◆ getLinearVelocity()
glm::vec2 pk::CharacterBody::getLinearVelocity |
( |
| ) |
|
|
inline |
Get the linear velocity of the body.
- Returns
- glm::vec2 - a vector of floats.
◆ getPosition()
glm::vec2 pk::CharacterBody::getPosition |
( |
| ) |
|
|
inline |
Get the position of the body in Box2D units (meters).
- Returns
- b2Vec2 - a Box2D vector of floats.
◆ getPositionInPixels()
glm::vec2 pk::CharacterBody::getPositionInPixels |
( |
| ) |
|
|
inline |
Get the position of the body in screen units (pixels).
- Returns
- glm::vec2 - a vector of floats.
◆ getRestitution()
float pk::CharacterBody::getRestitution |
( |
| ) |
|
|
inline |
Get the restitution of the body.
- Returns
- float - a plain old float.
◆ getRotation()
float pk::CharacterBody::getRotation |
( |
| ) |
|
|
inline |
Get the rotation for the CharacterBody.
- Returns
- float - a plain old float as degrees.
◆ getWorld()
b2World * pk::CharacterBody::getWorld |
( |
| ) |
|
|
inline |
Get a pointer to the Box2D world.
- Returns
- b2World* - a pointer to a Box2D b2World.
◆ leftSensor()
Get the left sensor data.
- Returns
- SensorData* - a pointer to the left sensor data.
◆ rightSensor()
Get the right sensor data.
- Returns
- SensorData* - a pointer to the right sensor data.
◆ setDensity()
void pk::CharacterBody::setDensity |
( |
float |
density | ) |
|
|
inline |
Set the density of the body.
- Parameters
-
float | density - a plain old float. |
◆ setFixedRotation()
void pk::CharacterBody::setFixedRotation |
( |
bool |
r | ) |
|
|
inline |
Set the body's rotation as fixed (no rotation).
- Parameters
-
bool | r - a plain old bool. |
◆ setFriction()
void pk::CharacterBody::setFriction |
( |
float |
friction | ) |
|
|
inline |
Set the friction for the body.
- Parameters
-
float | friction - a plain old float. |
◆ setLinearVelocity()
void pk::CharacterBody::setLinearVelocity |
( |
glm::vec2 |
v | ) |
|
|
inline |
Set the linear velocity of the body.
- Parameters
-
glm::vec2 | v - a vector of floats. |
◆ setPosition()
void pk::CharacterBody::setPosition |
( |
glm::vec2 |
position | ) |
|
|
inline |
Set the position of the CharacterBody.
- Parameters
-
glm::vec2 | position - a position as a glm::vec2 of floats. |
◆ setRestitution()
void pk::CharacterBody::setRestitution |
( |
float |
restitution | ) |
|
|
inline |
Set the restitution (bounciness) for the body.
- Parameters
-
float | restitution - a plain old float. |
◆ setTransform()
void pk::CharacterBody::setTransform |
( |
b2Vec2 |
position, |
|
|
float |
angle |
|
) |
| |
|
inline |
Set the transform data (position and angle) for the CharacterBody.
- Parameters
-
b2Vec2 | position - the position as a b2Vec2 of floats. |
float | angle - the angle as a float in degrees. |
◆ topSensor()
Get the top sensor data.
- Returns
- SensorData* - a pointer to the top sensor data.
◆ touchingWall()
bool pk::CharacterBody::touchingWall |
( |
| ) |
|
◆ m_body
b2Body* pk::CharacterBody::m_body |
|
private |
◆ m_bodyDef
b2BodyDef pk::CharacterBody::m_bodyDef |
|
private |
A Box2D body definition structure.
◆ m_characterID
int pk::CharacterBody::m_characterID |
|
private |
The unique id of the character body.
◆ m_fixtureDef
b2FixtureDef pk::CharacterBody::m_fixtureDef |
|
private |
A Box2D fixture definition structure.
◆ m_footSensorData
◆ m_leftSensorData
◆ m_rect
GLRect pk::CharacterBody::m_rect |
|
private |
◆ m_rightSensorData
◆ m_shape
b2PolygonShape pk::CharacterBody::m_shape |
|
private |
◆ m_topSensorData
◆ m_world
b2World* pk::CharacterBody::m_world |
|
private |
A pointer to a Box2D world.
The documentation for this class was generated from the following file: