A component that generates physics for a GameObject.
More...
#include <PhysicsComponent.hpp>
|
| PhysicsComponent (BodyType type, std::vector< Vector2 > points, float32 density, float32 friction, float32 restitution, bool managedByPhysics) |
| Constructs a new physics component. More...
|
|
| PhysicsComponent (BodyType type, float32 width, float32 height, float32 density, float32 friction, float32 restitution, bool managedByPhysics) |
| Constructs a new physics component. More...
|
|
void | Init () override |
| Initializes this component.
|
|
void | Update () override |
| Updates this component.
|
|
void | ApplyForce (Vector2 force, Vector2 point) |
| Applies the given force to the given point relative to this object. More...
|
|
void | ApplyForceToCenter (Vector2 force) |
| Applies the given force to the center of this object. More...
|
|
Vector2 | GetLinearVelocity () |
| Gets the linear velocity of this object. More...
|
|
void | SetLinearVelocity (Vector2 linear) |
| Sets the linear velocity of this object. More...
|
|
void | SetActive (bool active) |
| Sets the active state of the body of this physics component. More...
|
|
void | SetManagedByPhysics (bool managed) |
| Sets whether this physics component is managed by physics. More...
|
|
void | SetParentGameObject (std::weak_ptr< GameObject > g) |
| Sets the given GameObject as this component's parent. More...
|
|
std::shared_ptr< GameObject > | GetGameObject () |
| Gets a shared ptr reference to this component's GameObject. More...
|
|
|
void | SetupBodyWithShape (BodyType type, b2Shape *shape, float32 density, float32 friction, float32 restitution) |
| Sets up the Box2D body of this physics component with the given characteristics. More...
|
|
|
std::shared_ptr< b2BodyWrapper > | body |
| The Box2D body of this physics component.
|
|
bool | managedByPhysics |
| Whether or not this physics component is managed by physics.
|
|
const float | physicsScale = 200.0 |
| The scale of the physics relative to the world size.
|
|
A component that generates physics for a GameObject.
◆ PhysicsComponent() [1/2]
PhysicsComponent::PhysicsComponent |
( |
BodyType |
type, |
|
|
std::vector< Vector2 > |
points, |
|
|
float32 |
density, |
|
|
float32 |
friction, |
|
|
float32 |
restitution, |
|
|
bool |
managedByPhysics |
|
) |
| |
Constructs a new physics component.
- Parameters
-
type | The body type of this physics component |
points | List of points to define the shape of this component |
density | The density of this physics component |
friction | The friction of this physics component |
restitution | The restitution of this physics component |
managedByPhysics | Whether or not this physics component is managed by physics |
◆ PhysicsComponent() [2/2]
PhysicsComponent::PhysicsComponent |
( |
BodyType |
type, |
|
|
float32 |
width, |
|
|
float32 |
height, |
|
|
float32 |
density, |
|
|
float32 |
friction, |
|
|
float32 |
restitution, |
|
|
bool |
managedByPhysics |
|
) |
| |
Constructs a new physics component.
- Parameters
-
type | The body type of this physics component |
width | The width of this physics component |
height | The height of this physics component |
density | The density of this physics component |
friction | The friction of this physics component |
restitution | The restitution of this physics component |
managedByPhysics | Whether or not this physics component is managed by physics |
◆ ApplyForce()
Applies the given force to the given point relative to this object.
- Parameters
-
force | The force to be applied. |
point | The point the force will be applied to. |
◆ ApplyForceToCenter()
void PhysicsComponent::ApplyForceToCenter |
( |
Vector2 |
force | ) |
|
Applies the given force to the center of this object.
- Parameters
-
force | The force to be applied. |
◆ GetLinearVelocity()
Vector2 PhysicsComponent::GetLinearVelocity |
( |
| ) |
|
Gets the linear velocity of this object.
- Returns
- The linear velocity of this object.
◆ SetActive()
void PhysicsComponent::SetActive |
( |
bool |
active | ) |
|
Sets the active state of the body of this physics component.
- Parameters
-
active | Whether or not the body is active |
◆ SetLinearVelocity()
void PhysicsComponent::SetLinearVelocity |
( |
Vector2 |
linear | ) |
|
Sets the linear velocity of this object.
- Parameters
-
linear | The linear velocity to be set |
◆ SetManagedByPhysics()
void PhysicsComponent::SetManagedByPhysics |
( |
bool |
managed | ) |
|
Sets whether this physics component is managed by physics.
- Parameters
-
managed | Whether or not this physics component is managed by physics |
◆ SetupBodyWithShape()
void PhysicsComponent::SetupBodyWithShape |
( |
BodyType |
type, |
|
|
b2Shape * |
shape, |
|
|
float32 |
density, |
|
|
float32 |
friction, |
|
|
float32 |
restitution |
|
) |
| |
|
private |
Sets up the Box2D body of this physics component with the given characteristics.
- Parameters
-
type | The body type of the Box2D body. |
shape | The shape of the Box2D body. |
density | The density of the Box2D body. |
friction | The friction of the Box2D body. |
restitution | The restitution of the Box2D body. |
The documentation for this class was generated from the following files: