CUGL 2.3
Cornell University Game Library
|
#include <CUComplexObstacle.h>
Public Member Functions | |
ComplexObstacle () | |
virtual | ~ComplexObstacle () |
virtual b2BodyType | getBodyType () const override |
virtual void | setBodyType (b2BodyType value) override |
virtual Vec2 | getPosition () const override |
virtual void | setPosition (const Vec2 value) override |
virtual void | setPosition (float x, float y) override |
virtual float | getX () const override |
virtual void | setX (float value) override |
virtual float | getY () const override |
virtual void | setY (float value) override |
virtual float | getAngle () const override |
virtual void | setAngle (float value) override |
virtual Vec2 | getLinearVelocity () const override |
virtual void | setLinearVelocity (const Vec2 value) override |
virtual void | setLinearVelocity (float x, float y) override |
virtual float | getVX () const override |
virtual void | setVX (float value) override |
virtual float | getVY () const override |
virtual void | setVY (float value) override |
virtual float | getAngularVelocity () const override |
virtual void | setAngularVelocity (float value) override |
virtual bool | isEnabled () const override |
virtual void | setEnabled (bool value) override |
virtual bool | isAwake () const override |
virtual void | setAwake (bool value) override |
virtual bool | isSleepingAllowed () const override |
virtual void | setSleepingAllowed (bool value) override |
virtual bool | isBullet () const override |
virtual void | setBullet (bool value) override |
virtual bool | isFixedRotation () const override |
virtual void | setFixedRotation (bool value) override |
virtual float | getGravityScale () const override |
virtual void | setGravityScale (float value) override |
virtual float | getLinearDamping () const override |
virtual void | setLinearDamping (float value) override |
virtual float | getAngularDamping () const override |
virtual void | setAngularDamping (float value) override |
virtual void | setDensity (float value) override |
virtual void | setFriction (float value) override |
virtual void | setRestitution (float value) override |
virtual void | setSensor (bool value) override |
virtual void | setFilterData (b2Filter value) override |
virtual Vec2 | getCentroid () const override |
virtual void | setCentroid (const Vec2 value) override |
virtual void | setCentroid (float x, float y) override |
virtual float | getInertia () const override |
virtual void | setInertia (float value) override |
virtual float | getMass () const override |
virtual void | setMass (float value) override |
virtual void | resetMass () override |
virtual b2Body * | getBody () override |
const std::vector< std::shared_ptr< Obstacle > > & | getBodies () |
const std::vector< b2Joint * > & | getJoints () |
virtual bool | activatePhysics (b2World &world) override |
virtual void | deactivatePhysics (b2World &world) override |
virtual void | createFixtures () |
virtual void | releaseFixtures () |
virtual bool | createJoints (b2World &world) |
virtual void | update (float delta) override |
virtual void | setDebugColor (Color4 color) override |
void | setDebugColor (Color4 color, bool cascade) |
virtual void | setDebugScene (const std::shared_ptr< scene2::SceneNode > &node) override |
Public Member Functions inherited from cugl::physics2::Obstacle | |
Obstacle (void) | |
virtual | ~Obstacle () |
virtual bool | init () |
virtual bool | init (const Vec2 vec) |
virtual b2BodyType | getBodyType () const |
virtual void | setBodyType (b2BodyType value) |
virtual Vec2 | getPosition () const |
virtual void | setPosition (const Vec2 value) |
virtual void | setPosition (float x, float y) |
virtual float | getX () const |
virtual void | setX (float value) |
virtual float | getY () const |
virtual void | setY (float value) |
virtual float | getAngle () const |
virtual void | setAngle (float value) |
virtual Vec2 | getLinearVelocity () const |
virtual void | setLinearVelocity (const Vec2 value) |
virtual void | setLinearVelocity (float x, float y) |
virtual float | getVX () const |
virtual void | setVX (float value) |
virtual float | getVY () const |
virtual void | setVY (float value) |
virtual float | getAngularVelocity () const |
virtual void | setAngularVelocity (float value) |
virtual bool | isEnabled () const |
virtual void | setEnabled (bool value) |
virtual bool | isAwake () const |
virtual void | setAwake (bool value) |
virtual bool | isSleepingAllowed () const |
virtual void | setSleepingAllowed (bool value) |
virtual bool | isBullet () const |
virtual void | setBullet (bool value) |
virtual bool | isFixedRotation () const |
virtual void | setFixedRotation (bool value) |
virtual float | getGravityScale () const |
virtual void | setGravityScale (float value) |
virtual float | getLinearDamping () const |
virtual void | setLinearDamping (float value) |
virtual float | getAngularDamping () const |
virtual void | setAngularDamping (float value) |
void | setBodyState (const b2Body &body) |
float | getDensity () const |
virtual void | setDensity (float value) |
float | getFriction () const |
virtual void | setFriction (float value) |
float | getRestitution () const |
virtual void | setRestitution (float value) |
bool | isSensor () const |
virtual void | setSensor (bool value) |
b2Filter | getFilterData () const |
virtual void | setFilterData (b2Filter value) |
virtual Vec2 | getCentroid () const |
virtual void | setCentroid (const Vec2 value) |
virtual void | setCentroid (float x, float y) |
virtual float | getInertia () const |
virtual void | setInertia (float value) |
virtual float | getMass () const |
virtual void | setMass (float value) |
virtual void | resetMass () |
bool | isRemoved () const |
void | markRemoved (bool value) |
bool | isDirty () const |
void | markDirty (bool value) |
virtual b2Body * | getBody () |
virtual bool | activatePhysics (b2World &world) |
virtual void | deactivatePhysics (b2World &world) |
virtual void | update (float delta) |
const std::function< void(Obstacle *obstacle)> & | getListener () const |
void | setListener (const std::function< void(Obstacle *obstacle)> &listener) |
std::string | getName () const |
void | setName (std::string value) |
std::string | toString () const |
Color4 | getDebugColor () const |
virtual void | setDebugColor (Color4 color) |
scene2::SceneNode * | getDebugScene () const |
scene2::WireNode * | getDebugNode () const |
virtual void | setDebugScene (const std::shared_ptr< scene2::SceneNode > &node) |
bool | hasDebug () |
Protected Member Functions | |
virtual void | resetDebug () override |
virtual void | updateDebug () override |
virtual void | resetDebug () |
virtual void | updateDebug () |
Protected Attributes | |
b2Body * | _body |
std::vector< std::shared_ptr< Obstacle > > | _bodies |
std::vector< b2Joint * > | _joints |
Protected Attributes inherited from cugl::physics2::Obstacle | |
b2BodyDef | _bodyinfo |
b2FixtureDef | _fixture |
b2MassData | _massdata |
bool | _masseffect |
std::shared_ptr< scene2::SceneNode > | _scene |
std::shared_ptr< scene2::WireNode > | _debug |
Color4 | _dcolor |
std::string | _tag |
std::function< void(Obstacle *obstacle)> | _listener |
Composite model class to support collisions.
ComplexObstacle instances are built of many bodies, and are assumed to be connected by joints (though this is not actually a requirement). This is the class to use for chains, ropes, levers, and so on. This class does not provide Shape information, and cannot be instantiated directly. There are no default complex objects. You will need to create your own subclasses to use this class.
ComplexObstacle is a hierarchical class. It groups children as Obstacles, not not bodies. So you could have a ComplexObstacle made up of other ComplexObstacles. However, it is not the same as a scene graph. Children have absolute, nott relative, position data. Indeed, this class illustrates the need for decoupling the physics representation from the scene graph.
Transformations to an object of this class are restricted to the root body. They do not automatically effect the children (like a scene graph). If you want changes to the root body to effect the children, you should connect them with joints and allow Box2D to handle this.
Many of the method comments in this class are taken from the Box2d manual by Erin Catto (2011).
|
inline |
Creates a new complex physics object at the origin.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead (in this case, in one of the subclasses).
|
virtual |
Deletes this physics object and all of its resources.
We have to make the destructor public so that we can polymorphically delete physics objects.
The purpose of this destructor is to warn us if we delete an object pre-maturely.
|
overridevirtual |
Creates the physics Body(s) for this object, adding them to the world.
This method invokes ActivatePhysics for the individual PhysicsObjects in the list. It also calls the internal method createJoints() to link them all together. You should override that method, not this one, for specific physics objects.
world | Box2D world to store body |
Reimplemented from cugl::physics2::Obstacle.
|
inlinevirtual |
Create new fixtures for this body, defining the shape
This method is typically undefined for complex objects. While they need a root body, they rarely need a root shape. However, we provide this method for maximum flexibility.
|
inlinevirtual |
Creates the joints for this object.
This method is executed as part of activePhysics. This is the primary method to override for custom physics objects.
world | Box2D world to store joints |
|
overridevirtual |
Destroys the physics Body(s) of this object if applicable, removing them from the world.
world | Box2D world that stores body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the angle of rotation for this body (about the center).
The value is determined by the angle of the root object of this composite structure. The value returned is in radians.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the angular damping for this body.
Angular damping is use to reduce the angular velocity. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.
Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1.
This method only grabs the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the angular velocity for this physics body
This method uses the velocity for the root object of this composite structure. The rate of change is measured in radians per step
Reimplemented from cugl::physics2::Obstacle.
|
inline |
Returns the collection of component physics objects.
While the vector does not allow you to modify the list, it is possible to modify the individual objects.
|
inlineoverridevirtual |
Returns the Box2D body for this object.
This method only returrns the root body in this composite structure. For more fine-grain control, you should use the iterator methods.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the body type for Box2D physics
If you want to lock a body in place (e.g. a platform) set this value to STATIC. KINEMATIC allows the object to move (and some limited collisions), but ignores external forces (e.g. gravity). DYNAMIC makes this is a full-blown physics object.
This method returns the body type for the root object of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the center of mass of this body
This method does NOT return a reference to the centroid position. Changes to this vector will not affect the body. However, it returns the same vector each time its is called, and so cannot be used as an allocator.
This method returns the centroid for the root object of this composite structure. While it would make more sense to use the true centroid, that is much more computationally expensive, as that centroid is not rigid.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the gravity scale to apply to this body
This allows isolated objects to float. Be careful with this, since increased gravity can decrease stability.
This method only grabs the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the rotational inertia of this body
For static bodies, the mass and rotational inertia are set to zero. When a body has fixed rotation, its rotational inertia is zero.
This method only grabs the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inline |
Returns the collection of joints for this object (may be empty).
While the iterable does not allow you to modify the list, it is possible to modify the individual joints.
|
inlineoverridevirtual |
Returns the linear damping for this body.
Linear damping is use to reduce the linear velocity. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.
Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. Most people avoid linear damping because it makes bodies look floaty.
This method only grabs the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the linear velocity for this physics body
This method does NOT return a reference to the velocity vector. Changes to this vector will not affect the body. However, it returns the same vector each time its is called, and so cannot be used as an allocator.
This method returns the velocity for the root of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the mass of this body
The value is usually in kilograms. This method only grabs the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the current position for this physics body
This method does NOT return a reference to the position vector. Changes to this vector will not affect the body. However, it returns the same vector each time its is called, and so cannot be used as an allocator.
This method returns the position for the root object of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the x-velocity for this physics body
This method uses the velocity for the root of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the y-velocity for this physics body
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the x-coordinate for this physics body
This method uses the position for the root object of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns the y-coordinate for this physics body
This method uses the position for the root object of this composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns true if the body is awake
An sleeping body is one that has come to rest and the physics engine has decided to stop simulating it to save CPU cycles. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.
This method only tests the status of the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns true if this body is a bullet
By default, Box2D uses continuous collision detection (CCD) to prevent dynamic bodies from tunneling through static bodies. Normally CCD is not used between dynamic bodies. This is done to keep performance reasonable. In some game scenarios you need dynamic bodies to use CCD. For example, you may want to shoot a high speed bullet at a stack of dynamic bricks. Without CCD, the bullet might tunnel through the bricks.
Fast moving objects in Box2D can be labeled as bullets. Bullets will perform CCD with both static and dynamic bodies. You should decide what bodies should be bullets based on your game design.
This method only tests the status of the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns true if the body is enabled
A disabled body not participate in collision or dynamics. This state is similar to sleeping except the body will not be woken by other bodies and the body's fixtures will not be placed in the broad-phase. This means the body will not participate in collisions, ray casts, etc.
This method only tests the status of the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns true if this body be prevented from rotating
This is very useful for characters that should remain upright. This method only tests the status of the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Returns false if this body should never fall asleep
An sleeping body is one that has come to rest and the physics engine has decided to stop simulating it to save CPU cycles. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.
This method only tests the status of the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlinevirtual |
Release the fixtures for this body, reseting the shape
This method is typically undefined for complex objects. While they need a root body, they rarely need a root shape. However, we provide this method for maximum flexibility.
|
overrideprotectedvirtual |
Creates the outline of the physics fixtures in the debug wireframe
The debug wireframe is use to outline the fixtures attached to this object. This is very useful when the fixtures have a very different shape than the texture (e.g. a circular shape attached to a square texture).
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Resets this body to use the mass computed from the its shape and density.
This method only modifies the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the angle of rotation for this body (about the center).
This method sets the angle for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the angle of rotation for this body (in radians) |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the angular damping for this body.
Angular damping is use to reduce the angular velocity. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.
Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the angular damping for this body. |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the angular velocity for this physics body
This method sets the velocity for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the angular velocity for this physics body (in radians) |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets whether the body is awake
An sleeping body is one that has come to rest and the physics engine has decided to stop simulating it to save CPU cycles. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether the body is awake |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the body type for Box2D physics
If you want to lock a body in place (e.g. a platform) set this value to STATIC. KINEMATIC allows the object to move (and some limited collisions), but ignores external forces (e.g. gravity). DYNAMIC makes this is a full-blown physics object.
This sets the body type for the root body only. If you want to set the type of other objects in this class, iterate over the children.
value | the body type for Box2D physics |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets whether this body is a bullet
By default, Box2D uses continuous collision detection (CCD) to prevent dynamic bodies from tunneling through static bodies. Normally CCD is not used between dynamic bodies. This is done to keep performance reasonable. In some game scenarios you need dynamic bodies to use CCD. For example, you may want to shoot a high speed bullet at a stack of dynamic bricks. Without CCD, the bullet might tunnel through the bricks.
Fast moving objects in Box2D can be labeled as bullets. Bullets will perform CCD with both static and dynamic bodies. You should decide what bodies should be bullets based on your game design.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether this body is a bullet |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the center of mass for this physics body
This method converts from a Cocos2D vector type to a Box2D vector type. This cuts down on the confusion between vector types.
value | the center of mass for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the center of mass for this physics body
This method does not keep a reference to the parameter. This method sets the centroid for the root object of this composite structure. While it would make more sense to use the true centroid, that is much more computationally expensive, as that centroid is not rigid.
x | the x-coordinate of the center of mass for this physics body |
y | the y-coordinate of the center of mass for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets the color of the debug wireframe.
The default color is white, which means that the objects will be shown with a white wireframe.
color | the color of the debug wireframe. |
Reimplemented from cugl::physics2::Obstacle.
void cugl::physics2::ComplexObstacle::setDebugColor | ( | Color4 | color, |
bool | cascade | ||
) |
Sets the color of the debug wireframe.
The default color is white, which means that the objects will be shown with a white wireframe.
color | the color of the debug wireframe. |
cascade | whether to cascade the color to the component objects |
|
overridevirtual |
Sets the parent scene graph node for the debug wireframe
The given node is the parent coordinate space for drawing physics. All debug nodes for physics objects are drawn within this coordinate space. Setting the visibility of this node to false will disable any debugging. Similarly, setting this value to nullptr will disable any debugging.
This scene graph node is intended for debugging purposes only. If you want a physics body to update a proper texture image, you should either use the method update(float)
for subclasses or setListener
for decoupled classes.
node | he parent scene graph node for the debug wireframe |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets the density of this body
The density is typically measured in usually in kg/m^2. The density can be zero or positive. You should generally use similar densities for all your fixtures. This will improve stacking stability.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the density of this body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets whether the body is enabled
A disabled body not participate in collision or dynamics. This state is similar to sleeping except the body will not be woken by other bodies and the body's fixtures will not be placed in the broad-phase. This means the body will not participate in collisions, ray casts, etc.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether the body is active |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets the filter data for this object
Collision filtering allows you to prevent collision between fixtures. For example, say you make a character that rides a bicycle. You want the bicycle to collide with the terrain and the character to collide with the terrain, but you don't want the character to collide with the bicycle (because they must overlap). Box2D supports such collision filtering using categories and groups.
A value of null removes all collision filters. This method affects ALL of the bodies in this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
value | the filter data for this object |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets whether this body be prevented from rotating
This is very useful for characters that should remain upright.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether this body be prevented from rotating |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets the friction coefficient of this body
The friction parameter is usually set between 0 and 1, but can be any non-negative value. A friction value of 0 turns off friction and a value of 1 makes the friction strong. When the friction force is computed between two shapes, Box2D must combine the friction parameters of the two parent fixtures. This is done with the geometric mean.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the friction coefficient of this body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the gravity scale to apply to this body
This allows isolated objects to float. Be careful with this, since increased gravity can decrease stability.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the gravity scale to apply to this body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the rotational inertia of this body
For static bodies, the mass and rotational inertia are set to zero. When a body has fixed rotation, its rotational inertia is zero.
This method only modifies the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
value | the rotational inertia of this body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the linear damping for this body.
Linear damping is use to reduce the linear velocity. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together.
Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. Most people avoid linear damping because it makes bodies look floaty.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the linear damping for this body. |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the linear velocity for this physics body
This method converts from a Cocos2D vector type to a Box2D vector type. This cuts down on the confusion between vector types.
value | the linear velocity for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the linear velocity for this physics body
This method sets the linear velocity for the root of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
x | the x-coordinate of the linear velocity |
y | the y-coordinate of the linear velocity |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the mass of this body
The value is usually in kilograms. This method only modifies the parameter for the root object of this composite structure. For fine-grain control, you will need to loop over all elements in the composite structure.
value | the mass of this body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the current position for this physics body
This method converts from a Cocos2D vector type to a Box2D vector type. This cuts down on the confusion between vector types.
value | the current position for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the current position for this physics body
This method sets the position for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
x | the x-coordinate of the linear velocity |
y | the y-coordinate of the linear velocity |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets the restitution of this body
Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1. Consider dropping a ball on a table. A value of zero means the ball won't bounce. This is called an inelastic collision. A value of one means the ball's velocity will be exactly reflected. This is called a perfectly elastic collision.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | the restitution of this body |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Sets whether this object is a sensor.
Sometimes game logic needs to know when two entities overlap yet there should be no collision response. This is done by using sensors. A sensor is an entity that detects collision but does not produce a response.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether this object is a sensor. |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets whether the body should ever fall asleep
An sleeping body is one that has come to rest and the physics engine has decided to stop simulating it to save CPU cycles. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.
This method affects the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children.
value | whether the body should ever fall asleep |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the x-velocity for this physics body
This method sets the velocity for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the x-velocity for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the y-velocity for this physics body
This method sets the velocity for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the y-velocity for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the x-coordinate for this physics body
This method sets the position for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the x-coordinate for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
inlineoverridevirtual |
Sets the y-coordinate for this physics body
This method sets the position for the root body of this composite structure only. If you want to set the value for any of the child obstacles, iterate over the children. Alternatively attach the other children to the parent with joints so that they move together.
value | the y-coordinate for this physics body |
Reimplemented from cugl::physics2::Obstacle.
|
overridevirtual |
Updates the object's physics state (NOT GAME LOGIC).
This method is called AFTER the collision resolution state. Therefore, it should not be used to process actions or any other gameplay information. Its primary purpose is to adjust changes to the fixture, which have to take place after collision.
delta | Timing values from parent loop |
Reimplemented from cugl::physics2::Obstacle.
|
overrideprotectedvirtual |
Repositions the debug wireframe so that it agrees with the physics object.
The debug wireframe is use to outline the fixtures attached to this object. This is very useful when the fixtures have a very different shape than the texture (e.g. a circular shape attached to a square texture).
Reimplemented from cugl::physics2::Obstacle.
|
protected |
A complex physics object has multiple bodies
|
protected |
A root body for this box 2d.
|
protected |
Potential joints for connecting the multiple bodies