Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
Joint2D Class Referenceabstract

An Joint2D object connects two physics bodies together. More...

#include <Joint2D.h>

Inherited by DistanceJoint2D, FilterJoint2D, FixedJoint2D, and .

Public Member Functions

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.

Detailed Description

An Joint2D object connects two physics bodies together.

Member Function Documentation

◆ isAttached()

bool isAttached ( ) const
inline

Check if this joint is currently attached to the physics world.

Returns
True if the joint is valid and attached, false otherwise.

◆ getWorld()

PhysicsWorld2D * getWorld ( ) const
inline

Get the physics world that owns this joint.

Returns
Pointer to the PhysicsWorld2D instance.

◆ getAttachedBody()

Rigidbody2D * getAttachedBody ( ) const
inline

Get the primary body (body A) attached to this joint.

Returns
Pointer to the attached Rigidbody2D.

◆ setConnectedBody()

void setConnectedBody ( Rigidbody2D * body)

Set the secondary body (body B) connected to this joint.

Parameters
bodyPointer to the Rigidbody2D to connect.

◆ getConnectedBody()

Rigidbody2D * getConnectedBody ( ) const
inline

Get the secondary body (body B) connected to this joint.

Returns
Pointer to the connected Rigidbody2D.

◆ getAnchorSpace()

AnchorSpace getAnchorSpace ( ) const
inline

Get the current anchor space mode.

Returns
The anchor space (local or world).

◆ setAnchorSpace()

void setAnchorSpace ( AnchorSpace space)
inline

Set the anchor space mode.

Parameters
spaceThe anchor space (local or world).

◆ setAnchorsInWorldSpace()

void setAnchorsInWorldSpace ( const Vec2 & anchor)

Set both attached and connected anchors in world coordinates.

This method forces the joint to use world space for anchors. Both the attached body anchor and the connected body anchor will be set to the same world-space position provided.

Parameters
anchorThe anchor position in world space.

◆ getAnchor()

Vec2 getAnchor ( ) const
inline

Get the anchor point of the attached body.

Returns
The anchor position in current coordinate space.

◆ setAnchors()

void setAnchors ( const Vec2 & anchor,
const Vec2 & connectedAnchor )
inline

Set both anchors in the current coordinate space.

Parameters
anchorAnchor position for the attached body.
connectedAnchorAnchor position for the connected body.

◆ setAnchor()

void setAnchor ( const Vec2 & anchor)

Set the anchor point of the attached body in the current coordinate space.

Parameters
anchorThe anchor position.

◆ getConnectedAnchor()

Vec2 getConnectedAnchor ( ) const
inline

Get the anchor point of the connected body.

Returns
The connected anchor position in current coordinate space.

◆ setConnectedAnchor()

void setConnectedAnchor ( const Vec2 & anchor)

Set the anchor point of the connected body in the current coordinate space.

Parameters
anchorThe connected anchor position.

◆ isCollisionEnabled()

bool isCollisionEnabled ( ) const
inline

Check if collision between the two bodies is enabled.

Returns
True if collision is enabled, false otherwise.

◆ setCollisionEnabled()

void setCollisionEnabled ( bool enable)

Enable or disable collision between the two bodies connected by this joint.

Parameters
enableTrue to enable collision, false to disable.

◆ setAutoConfigureConnectedAnchor()

void setAutoConfigureConnectedAnchor ( bool val)

Enable or disable automatic configuration of the connected anchor.

Parameters
valTrue to auto-configure, false to use manual settings.

◆ isAutoConfigureConnectedAnchor()

bool isAutoConfigureConnectedAnchor ( ) const
inline

Check if automatic configuration of the connected anchor is enabled.

Returns
True if auto-configuration is enabled, false otherwise.

◆ setDrawScale()

void setDrawScale ( float scale)
inline

Set the debug draw scale for this joint.

A scale of 0 disables joint debug drawing. This depends on Axmol's modifications to Box2D joint rendering logic.

Parameters
scaleThe scale factor for debug drawing.

◆ getTag()

int getTag ( ) const
inline

Get this joint's tag.

Returns
An integer identifier for the joint.

◆ setTag()

void setTag ( int tag)
inline

Set this joint's tag.

Parameters
tagAn integer identifier for the joint.

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