Class PhysicsWorld
The PhysicsWorld provides:
Global values such as Gravity. Connecting PhysicsBodies with the AddJoint(PhysicsJoint) method. Raising events when PhysicsBody begin or end contact with each other(DidBeginContact, DidEndContact).
public sealed class PhysicsWorld
- Inheritance
-
PhysicsWorld
- Inherited Members
Properties
DefaultCollisionHandler
event when two bodies contact begin
public ContactHandler DefaultCollisionHandler { get; }
Property Value
Gravity
Gravitational acceleration
public Vector2 Gravity { get; set; }
Property Value
Iterations
Number of iterations to be used by impulse solver The default value is 10, for a more precise use a higher value For a faster solver use a lower value (This only affect Chipmunk/MonoGame backend)
public int Iterations { get; set; }
Property Value
Speed
The speed at which the physics simulation runs.
public float Speed { get; set; }
Property Value
Methods
AddJoint(PhysicsJoint)
Add joint to world
public void AddJoint(PhysicsJoint joint)
Parameters
joint
PhysicsJoint
EnumarateBodies(PointF)
Enumerate all physical bodies at point
public PhysicsBody[] EnumarateBodies(PointF point)
Parameters
point
PointF
Returns
EnumarateBodies(PointF, int)
Enumerate all physical bodies at point that match the filter
public PhysicsBody[] EnumarateBodies(PointF point, int categories)
Parameters
Returns
EnumarateBodies(RectangleF)
Enumerate all physical bodies inside the rectangle
public PhysicsBody[] EnumarateBodies(RectangleF rect)
Parameters
rect
RectangleF
Returns
EnumarateBodies(RectangleF, int)
Enumerate all physical bodies inside the rectangle and match the filter
public PhysicsBody[] EnumarateBodies(RectangleF rect, int categories)
Parameters
rect
RectangleFcategories
int
Returns
GetBody(PointF)
Returns the first PhysicsBody found that contains a point.
public PhysicsBody GetBody(PointF point)
Parameters
point
PointF
Returns
GetBody(PointF, int)
Get the physical body at point that match the filter mask
public PhysicsBody GetBody(PointF point, int category)
Parameters
Returns
GetBody(RectangleF)
Returns the first PhysicsBody whose shape intersects a rectangle.
public PhysicsBody GetBody(RectangleF rect)
Parameters
rect
RectangleF
Returns
GetBody(RectangleF, int)
Get the first body inside the rectangle bound that match the filter
public PhysicsBody GetBody(RectangleF rect, int category)
Parameters
rect
RectangleFcategory
int
Returns
GetPairCollisionHandler(int, int)
event when two bodies contact begin
public ContactHandler GetPairCollisionHandler(int collisionTypeA, int collisionTypeB)
Parameters
Returns
Raycast(PointF, PointF)
Returns the first PhysicsBody that intersects a ray defined by two points.
public RaycastHit Raycast(PointF rayStart, PointF rayEnd)
Parameters
Returns
Raycast(PointF, PointF, int)
Return the first body that intersect with the raycast
public RaycastHit Raycast(PointF rayStart, PointF rayEnd, int categories)
Parameters
Returns
RaycastBodies(PointF, PointF)
Get all bodies that intersect the raycast
public RaycastHit[] RaycastBodies(PointF rayStart, PointF rayEnd)
Parameters
Returns
RaycastBodies(PointF, PointF, int)
Get all bodies that intersect the raycast and match the filter
public RaycastHit[] RaycastBodies(PointF rayStart, PointF rayEnd, int categories)
Parameters
Returns
RemoveAllJoints()
Removes all PhysicsJoints.
public void RemoveAllJoints()
RemoveJoint(PhysicsJoint)
Removes the specified PhysicsJoint.
public void RemoveJoint(PhysicsJoint joint)
Parameters
joint
PhysicsJoint