Sprite Physics API
- Sub GetSpriteCenter(spr_id, ByRef x, ByRef y)
Returns a sprites center of mass.
- Sub SetSpriteLinearVelocity(spr_id, x, y)
Sets a sprite’s linear velocity.
See also
GetSpriteLinearVelocity()
- Sub GetSpriteLinearVelocity(spr_id, ByRef x, ByRef y)
Gets the linear velocity of a sprite.
See also
SetSpriteLinearVelocity()
- Sub SetSpriteAngularVelocity(spr_id, av)
Sets the angular velocity of a sprite.
See also
GetSpriteAngularVelocity()
- Function GetSpriteAngularVelocity(spr_id)
Returns the angular velocity.
- Sub ApplySpriteForce(spr_id, fX, fY, pX, pY)
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
- Sub ApplySpriteCentralForce(spr_id, x, y)
Apply a continuous force to a body at its center of mass, regardless of the body’s current orientation. This method affects the body’s linear motion and is useful for simulating forces like gravity, wind, or any other directional force.
- Sub ApplySpriteTorque(spr_id, torque)
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass.
- Sub ApplySpriteLinearImpulse(spr_id, iX, iY, pX, pY)
Apply an instantaneous linear impulse to a body. This method directly affects the body’s linear motion by changing its velocity based on the impulse applied.
See also
ApplySpriteAngularImpulse()
- Sub ApplySpriteAngularImpulse(spr_id, impulse)
Apply an angular impulse to a body. This method affects the body’s rotational motion, changing its angular velocity based on the impulse applied.
See also
ApplySpriteLinearImpulse()
- Function GetSpriteMass(spr_id)
Returns the total mass of the body.
- Function GetSpriteInertia(spr_id)
Returns the rotational inertia of the body about the local origin.
- Sub GetSpriteWorldPoint(spr_id, lX, lY, ByRef x, ByRef y)
Get the world coordinates of a point given the local coordinates.
- Sub GetSpriteWorldVector(spr_id, lX, lY, ByRef x, ByRef y)
Get the world coordinates of a vector given the local coordinates.
- Sub GetSpriteLocalPoint(spr_id, wX, wY, ByRef x, ByRef y)
Gets a local point relative to the body’s origin given a world point.
- Sub GetSpriteLocalVector(spr_id, wX, wY, ByRef x, ByRef y)
Gets a local vector given a world vector.
- Sub GetSpriteLinearVelocityFromLocalPoint(spr_id, pX, pY, ByRef x, ByRef y)
Get the world velocity of a local point.
- Sub GetSpriteLinearVelocityFromWorldPoint(spr_id, wX, wY, ByRef x, ByRef y)
Get the world linear velocity of a world point attached to this body.
- Sub SetSpriteLinearDamping(spr_id, linearDamping)
Sets the linear damping of a sprite.
See also
GetSpriteLinearDamping()
- Function GetSpriteLinearDamping(spr_id)
Returns a sprite’s linear damping value.
See also
SetSpriteLinearDamping()
- Sub SetSpriteAngularDamping(spr_id, angularDamping)
Sets a sprite’s angular damping.
See also
GetSpriteAngularDamping()
- Function GetSpriteAngularDamping(spr_id)
Returns a sprite’s angular damping.
See also
ApplySpriteAngularDamping()
- Sub SetSpriteGravityScale(spr_id, g_scale)
Sets the affect of gravity on a sprite.
See also
GetSpriteGravityScale()
- Function GetSpriteGravityScale(spr_id)
Returns a sprite’s gravity scale.
See also
SetSpriteGravityScale()
- Sub SetSpriteBullet(spr_id, flag)
Sets whether body has continuous collision detection
Note: Useful for fast moving objects.
See also
SpriteIsBullet()
- Function SpriteIsBullet(spr_id)
Returns whether body has continuous collision detection
Note: Useful for fast moving objects.
See also
SetSpriteBullet()
- Sub SetSpriteSleepAllowed(spr_id, flag)
Sets whether the sprite is allowed to go to sleep when it’s at rest.
See also
SetSpriteAwake(),SpriteIsAwake(),SpriteIsSleepAllowed()
- Function SpriteSleepAllowed(spr_id)
Whether the body is allowed to go to sleep when it’s at rest.
See also
SetSpriteSleepAllowed(),SpriteIsAwake(),SetSpriteAwake()
- Sub SetSpriteAwake(spr_id, flag)
Sets a sprite’s sleep state.
- Function SpriteIsAwake(spr_id)
Wakes a sleeping sprite.
See also
SetSpriteAwake(),SpriteIsSleepAllowed(),SetSpriteSleepAllowed()
- Sub SetSpriteFixedRotation(spr_id, flag)
Prevents sprite from being rotated by any forces applied to it.
See also
- Function SpriteIsFixedRotation(spr_id)
Returns whether fixed rotation is set on the sprite.
See also
SetSpriteFixedRotation()
- Sub SetSpriteDensity(spr_id, density)
Sets the density of a sprite. Higher density means a heavier sprite. Density is used to calculate mass for a sprite.
See also
- Function GetSpriteDensity(spr_id)
Returns the density of a sprite. Higher density means a heavier sprite.
See also
- Sub SetSpriteFriction(spr_id, friction)
Sets a sprite’s friction.
See also
- Function GetSpriteFriction(spr_id)
Returns a sprite’s friction.
See also
- Sub SetSpriteRestitution(spr_id, restitution)
Sets the restitution coefficient for a sprite.
See also
- Function GetSpriteRestitution(spr_id)
Returns the restitution coefficient for a sprite.
See also
- Sub SetSpriteRestitutionThreshold(spr_id, threshold)
Sets the restitution threshold for a sprite.
See also
- Function GetSpriteRestitutionThreshold(spr_id)
Returns the restitution velocity threshold for a sprite.
See also
- Sub GetSpriteAABB(spr_id, ByRef x1, ByRef y1, ByRef x2, ByRef y2)
Returns the axis aligned bounding box for a sprite.
- Sub SetGravity2D(x, y)
Use this function for setting the global gravity vector. A sprite canvas layer must be active.
See also
- Sub GetGravity2D(ByRef x, ByRef y)
Use this function for retrieving the global gravity vector. A sprite canvas layer must be open.
See also
- Sub SetWorld2DTimeStep(ts)
Sets the timestep for the active canvas.
See also
- Sub SetWorld2DVelocityIterations(v)
Sets the number of velocity iterations for the velocity constraint solver.
See also
- Sub SetWorld2DPositionIterations(p)
Sets the number of position iterations for the position constraint solver.
See also
- Function GetWorld2DTimeStep()
Returns the timestep for the active canvas.Sub
See also
- Function GetWorld2DVelocityIterations()
Returns the number of velocity iterations for the velocity constraint solver.
See also
- Function GetWorld2DPositionIterations()
Returns the number of position iterations for the position constraint solver.
See also
- Sub SetWorld2DAutoClearForces(flag)
Sets the auto clear forces flag for the active canvas.
See also
- Function GetWorld2DAutoClearForces()
Returns the auto clear forces flag for the active canvas.
See also
- Function CastRay2D(from_x, from_y, to_x, to_y)
Cast a ray and get the closest hit on the ray Returns 1 if there is a hit and 0 if not NOTE: GetRayHit2D is used to read each hit.
See also
GetRayHit3D(),CastRay3D(),CastRay3D_All(),CastRay2D_All(),GetRayHit2D()
- Function CastRay2D_All(from_x, from_y, to_x, to_y)
Cast a ray and gets all hits on the ray Returns the number of hits from the ray cast NOTE: GetRayHit2D is used to read each hit.
See also
GetRayHit3D(),CastRay3D(),CastRay3D_All(),CastRay2D(),GetRayHit2D()
- Sub GetRayHit2D(index, ByRef spr_id, ByRef x, ByRef y, ByRef normal_x, ByRef normal_y)
This function will get the collision point and the normal of a ray hit.
NOTES:
- CastRay2D or CastRay2D_All must be called prior to calling this function.
- spr_id will return -1 if there was not a hit at the specified index.
See also
GetRayHit3D(),CastRay3D(),CastRay3D_All(),CastRay2D(),CastRay2D_All()
- Sub SetSpriteShape(spr_id, shape)
Sets the shape of a sprite.
Possible Shapes:
- SPRITE_SHAPE_NONE
- SPRITE_SHAPE_BOX - A rectangular shape.
- SPRITE_SHAPE_POLYGON - A polygon (any shape with 3 or more sides).
- SPRITE_SHAPE_CIRCLE - A circle.
- SPRITE_SHAPE_CHAIN - A open polygon shape.
- NOTE: Mainly used for terrain.
See also
- Function GetSpriteShape(spr_id)
Sets the shape of a sprite.
Possible Shapes:
- SPRITE_SHAPE_NONE
- SPRITE_SHAPE_BOX - A rectangular shape.
- SPRITE_SHAPE_POLYGON - A polygon (any shape with 3 or more sides).
- SPRITE_SHAPE_CIRCLE - A circle.
- SPRITE_SHAPE_CHAIN - A open polygon shape.
- NOTE: Mainly used for terrain.
See also
- Sub SetSpriteRadius(spr_id, radius)
Sets the radius of a sprites collision shape.
NOTE: Does nothing if collision shape is not SPRITE_SHAPE_CIRCLE.
See also
- Function GetSpriteRadius(spr_id)
Returns the radius of a sprites collision shape.
NOTE: Returns 0 if collision shape is not SPRITE_SHAPE_CIRCLE
See also
- Sub SetSpriteBox(spr_id, w, h)
Sets the width and Height of a sprite collision box
NOTE: Sprite collision shape must be SPRITE_SHAPE_BOX.
- Sub GetSpriteBoxSize(spr_id, ByRef w, ByRef h)
Returns the size of the collision box on a sprite.
NOTE: Returns (-1, -1) if the collision shape is not a box.
See also
- Sub SetSpriteChain(spr_id, ByRef vx, ByRef vy, v_count, prev_x, prev_y, next_x, next_y)
Sets the points in a collision chain.
NOTE: Sprite collision shape must be SPRITE_SHAPE_CHAIN.
- Sub SetSpriteChainLoop(spr_id, ByRef vx, ByRef vy, v_count)
Sets the points in a collision chain loop .
NOTE: Since it is a loop, the shape will be a closed.
NOTE: Sprite collision shape must be SPRITE_SHAPE_CHAIN.
- Sub SetSpritePolygon(spr_id, ByRef vx, ByRef vy, v_count)
Sets the points in a polygon sprite shape.
- Sub SetSpriteShapeOffset(spr_id, x, y)
Sets the relative location the sprite shape is from where it is rendered.
See also
- Sub GetSpriteShapeOffset(spr_id, ByRef x, ByRef y)
Gets the relative location the sprite shape is from where it is rendered.
See also
SetSpriteShapeOffset()
- Sub GetSpriteWorldCenter(spr_id, ByRef x, ByRef y)
Gets the center of a sprite’s shape as world coordinates.