Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
SpringJoint2D Class Reference

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

#include <Joint2D.h>

Inherits Joint2D.

Public Member Functions

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.
Public Member Functions inherited from Joint2D
bool isAttached () const
 Check if this joint is currently attached to the physics world.
PhysicsWorld2D * getWorld () const
 Get the physics world that owns this joint.
Rigidbody2D * getAttachedBody () const
 Get the primary body (body A) attached to this joint.
void setConnectedBody (Rigidbody2D *body)
 Set the secondary body (body B) connected to this joint.
Rigidbody2D * getConnectedBody () const
 Get the secondary body (body B) connected to this joint.
AnchorSpace getAnchorSpace () const
 Get the current anchor space mode.
void setAnchorSpace (AnchorSpace space)
 Set the anchor space mode.
void setAnchorsInWorldSpace (const Vec2 &anchor)
 Set both attached and connected anchors in world coordinates.
Vec2 getAnchor () const
 Get the anchor point of the attached body.
void setAnchors (const Vec2 &anchor, const Vec2 &connectedAnchor)
 Set both anchors in the current coordinate space.
void setAnchor (const Vec2 &anchor)
 Set the anchor point of the attached body in the current coordinate space.
Vec2 getConnectedAnchor () const
 Get the anchor point of the connected body.
void setConnectedAnchor (const Vec2 &anchor)
 Set the anchor point of the connected body in the current coordinate space.
bool isCollisionEnabled () const
 Check if collision between the two bodies is enabled.
void setCollisionEnabled (bool enable)
 Enable or disable collision between the two bodies connected by this joint.
void setAutoConfigureConnectedAnchor (bool val)
 Enable or disable automatic configuration of the connected anchor.
bool isAutoConfigureConnectedAnchor () const
 Check if automatic configuration of the connected anchor is enabled.
void setDrawScale (float scale)
 Set the debug draw scale for this joint.
int getTag () const
 Get this joint's tag.
void setTag (int tag)
 Set this joint's tag.

Static Public Member Functions

static SpringJoint2D * create (float stiffness, float damping, Rigidbody2D *connectedBody)
 Create a Spring joint.

Detailed Description

Connecting two physics bodies together with a spring.

Member Function Documentation

◆ create()

SpringJoint2D * create ( float stiffness,
float damping,
Rigidbody2D * connectedBody )
static

Create a Spring joint.

Parameters
stiffnessIt's the spring constant.
dampingIt's how soft to make the damping of the spring.
Returns
A object pointer.

The documentation for this class was generated from the following file:
  • Joint2D.h