Cocos2d-x  4.0.0
Public Member Functions | Static Public Member Functions | List of all members
PhysicsJointSpring Class Reference

Connecting two physics bodies together with a spring. More...

Inherits PhysicsJoint.

Public Member Functions

Vec2 getAnchr1 () const
 Get the anchor point on body a.
 
void setAnchr1 (const Vec2 &anchr1)
 Set the anchor point on body a.
 
Vec2 getAnchr2 () const
 Get the anchor point on body b.
 
void setAnchr2 (const Vec2 &anchr2)
 Set the anchor point on body b.
 
float getRestLength () const
 Get the distance of the anchor points.
 
void setRestLength (float restLength)
 Set the distance of the anchor points.
 
float getStiffness () const
 Get the spring constant.
 
void setStiffness (float stiffness)
 Set the spring constant.
 
float getDamping () const
 Get the spring soft constant.
 
void setDamping (float damping)
 Set the spring soft constant.
 
virtual bool createConstraints () override
 Create constraints for this type joint.
 
- Public Member Functions inherited from PhysicsJoint
PhysicsBodygetBodyA () const
 Get physics body a connected to this joint.
 
PhysicsBodygetBodyB () const
 Get physics body b connected to this joint.
 
PhysicsWorldgetWorld () const
 Get the physics world.
 
int getTag () const
 Get this joint's tag.
 
void setTag (int tag)
 Set this joint's tag.
 
bool isEnabled () const
 Determines if the joint is enable.
 
void setEnable (bool enable)
 Enable/Disable the joint.
 
bool isCollisionEnabled () const
 Determines if the collision is enable.
 
void setCollisionEnable (bool enable)
 Enable/disable the collision between two bodies.
 
void removeFormWorld ()
 Remove the joint from the world.
 
void setMaxForce (float force)
 Set the max force between two bodies.
 
float getMaxForce () const
 Get the max force setting.
 

Static Public Member Functions

static PhysicsJointSpringconstruct (PhysicsBody *a, PhysicsBody *b, const Vec2 &anchr1, const Vec2 &anchr2, float stiffness, float damping)
 Create a fixed distance joint.
 

Detailed Description

Connecting two physics bodies together with a spring.

Member Function Documentation

static PhysicsJointSpring* construct ( PhysicsBody a,
PhysicsBody b,
const Vec2 anchr1,
const Vec2 anchr2,
float  stiffness,
float  damping 
)
static

Create a fixed distance joint.

Parameters
aA is the body to connect.
bB is the body to connect.
anchr1Anchr1 is the anchor point on body a.
anchr2Anchr2 is the anchor point on body b.
stiffnessIt's the spring constant.
dampingIt's how soft to make the damping of the spring.
Returns
A object pointer.
Vec2 getAnchr1 ( ) const

Get the anchor point on body a.

void setAnchr1 ( const Vec2 anchr1)

Set the anchor point on body a.

Vec2 getAnchr2 ( ) const

Get the anchor point on body b.

void setAnchr2 ( const Vec2 anchr2)

Set the anchor point on body b.

float getRestLength ( ) const

Get the distance of the anchor points.

void setRestLength ( float  restLength)

Set the distance of the anchor points.

float getStiffness ( ) const

Get the spring constant.

void setStiffness ( float  stiffness)

Set the spring constant.

float getDamping ( ) const

Get the spring soft constant.

void setDamping ( float  damping)

Set the spring soft constant.


The documentation for this class was generated from the following file: