C# Класс LitDev.LDPhysics

Показать файл Открыть проект

Открытые методы

Метод Описание
AddChain ( Primitive shape1, Primitive shape2 ) : Primitive

Add a chain between two existing shapes.

AddExplosion ( Primitive posX, Primitive posY, Primitive power, Primitive damping, Primitive colour ) : void

Make an explosion, which consists of 50x20kg particles blast apart over 500ms.

AddFixedAnchor ( Primitive posX, Primitive posY ) : Primitive

Add a new small, transparent shape to be used as a fixed anchor point.

AddFixedShape ( Primitive shapeName, Primitive friction, Primitive restitution ) : void

Add an existing SmallBasic shape to the physics engine as a fixed (non-dynamic) shape with friction and restitution that affects shapes that hit it.

AddInactiveShape ( Primitive shapeName ) : void

Add an existing SmallBasic shape to the physics engine as an inactive (non-dynamic and non-interacting) shape which only moves with the PanView method.

AddMovingAnchor ( Primitive posX, Primitive posY ) : Primitive

Add a new small, transparent and high density shape to be used as a moving anchor point.

AddMovingShape ( Primitive shapeName, Primitive friction, Primitive restitution, Primitive density ) : void

Add an existing SmallBasic shape to the physics engine as a moving (dynamic) shape.

AddRope ( Primitive shape1, Primitive shape2 ) : Primitive

Add a rope between two existing shapes.

AttachShapes ( Primitive shape1, Primitive shape2 ) : void

Connect two shapes to move together as one. The shapes are connected with a distance joint and may wobble a bit if they are hit.

AttachShapesWithJoint ( Primitive shape1, Primitive shape2, Primitive type, Primitive collide, Primitive parameters ) : Primitive

Connect two shapes to move together as one with one of several joint types. These can be advanced and require reference to Box2D manual. In many cases it is best to prevent shape rotation for the joints to behave as desired. Multiple joints may also be applied to shapes. The methods use the initial shape positions, so set these first.

AttachShapesWithRotation ( Primitive shape1, Primitive shape2 ) : void

Connect two shapes to move together as one, but allow the shapes to rotate about each other.

BoxShape ( Primitive shapeName, Primitive x1, Primitive y1, Primitive x2, Primitive y2 ) : void

Set a shape to remain within a box within the view. This is similar to PanView, except that the view pans automatically to keep the specified shape within a box region of the GraphicsWindow. Only one shape can be boxed. To unset shape box, set the shapeName to "".

BrakeTire ( Primitive shapeName ) : void

Apply a brake to a tire shape.

DetachJoint ( Primitive jointName ) : void

Disconnect two shapes that were previously joined with a joint.

DetachShapes ( Primitive shape1, Primitive shape2 ) : void

Disconnect two shapes that were previously attached.

DisconnectShape ( Primitive shapeName ) : void

Disconnect shape from the physics engine without deleting the shape.

DoTimestep ( ) : void

Perform a time-step update.

FollowShapeX ( Primitive shapeName ) : void

Set a shape to remain stationary at X position in the view. This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual X location. Only one shape can be followed in X direction. To unset shape following, set the shapeName to "".

FollowShapeY ( Primitive shapeName ) : void

Set a shape to remain stationary at Y position in the view. This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual Y location. Only one shape can be followed in Y direction. To unset shape following, set the shapeName to "".

GetAllShapesAt ( Primitive posX, Primitive posY ) : Primitive

Get an array of all the physics engine shapes (if any) at the input coordinates. The coordinates for this method are the physics engine coordinates if panning is present.

GetAngle ( Primitive shapeName ) : Primitive

Get the angle of rotation for the shape.

GetCollisions ( Primitive shapeName ) : Primitive

Get an array of all the shapes that the specified shape collided with during the last DoTimestep().

GetContacts ( Primitive posX, Primitive posY, Primitive distance ) : Primitive

Get a list of shapes that collided within a distance of a specified contact point.

GetInertia ( Primitive shapeName ) : Primitive

Get the moment of inertia of a shape.

GetMass ( Primitive shapeName ) : Primitive

Get the mass of a shape.

GetPan ( ) : Primitive

Get the current pan offset, see PanView, FollowShapeX(Y) and BoxShape. World coordinates = screen coordinates + pan offset.

GetPosition ( Primitive shapeName ) : Primitive

Get the centre of the shape coordinates.

GetRotation ( Primitive shapeName ) : Primitive

Get the shape rotation speed.

GetShapeAt ( Primitive posX, Primitive posY ) : Primitive

Get the shape (if any) at the input coordinates. The coordinates for this method are the screen coordinates if panning is present.

GetTireInformation ( Primitive shapeName ) : Primitive

Get tire information, it includes: Skid (if this value exceeds the property AntiSkid, then the tire is skidding) Crash (the value is the speed of the impact)

GetTireProperties ( Primitive shapeName ) : Primitive

Get tire properties, they include: AntiSkid (higher value reduces skid) Drag (higher value increases forward/backward drag) Brake (higher value increases braking power) Straighten (higher value restores steering more quickly) BrakeStraighten (higher value restores steering more quickly while braking)

GetVelocity ( Primitive shapeName ) : Primitive

Get the velocity of the shape.

GroupShapes ( Primitive shape1, Primitive shape2 ) : void

Solidly group two shapes to move together as one. Shape1 is added to shape2 to act as one shape.

Help ( ) : void

This function is just to display this help. The extension uses Box2D (http://box2d.org) as an engine and provides an interface between it and the graphics capabilities of SmallBasic. Only shapes that are connected to the physics engine take part in the motion physics, for example you may add normal shapes (e.g. a gun and not connect it to the physics engine). Once a shape is connected to the engine, it is best to only interact with it through the methods provided by the extension. All positions are in the SmallBasic GraphicsWindow pixels and refer to shape centres. Image and text shapes are treated as rectangles, and ellipses as circles; there is also triangle and convex polygon support, but not lines. Images may be treated as circles by setting the property LoadImagesAsCircles to "True". One issue that Box2D has difficulty with is small fast moving objects that can 'tunnel' through other shapes without being deflected (see the SetBullet option). Another problem is shapes of very different size and hence mass, especially large shapes when they are connected together. It may be necessary to modify the density for these (the Anchor options are an attempt to automate this a bit), otherwise the default density of 1 is good. Resist the temptation to connect too many shapes together. It may be possible to improve the stability of some 'difficult' models using the TimestepControl settings, but the defaults look good for most cases. Do not call the physics methods inside SmallBasic event subroutines directly, rather set flags that can be processed in a main game loop. There are sample SmallBasic programs and a Getting Started Guide that comes with the extension dll - this is the best place to start. Report bugs and problems to the SmallBasic forum (http://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads), but first simplify your SmallBasic code to isolate the issue before providing a short 'runnable' code sample.

MoveTire ( Primitive shapeName, Primitive force ) : void

Move a tire shape, apply a forward or backward force.

PanView ( Primitive panHorizontal, Primitive panVertical ) : void

Pan the camera view, including window boundaries.

RayCast ( Primitive shapeName, Primitive angle, Primitive distance ) : Primitive

Cast an invisible ray to detect the proximity of shapes.

ReadJson ( Primitive fileName, Primitive scale, Primitive reverseY, Primitive stationary, Primitive offsetX, Primitive offsetY ) : Primitive

Read in a json script compatible with R.U.B.E. and create a LDPhysics model. See https://www.iforce2d.net/rube for more details.

RemoveChain ( Primitive shapeName ) : void

Remove a chain.

RemoveFrozen ( ) : void

Removes all frozen shapes - outside the AABB for the engine.

RemoveRope ( Primitive shapeName ) : void

Remove a rope.

RemoveShape ( Primitive shapeName ) : void

Remove a shape.

Reset ( ) : void

Reset (delete all physics engine attached shapes).

SetAABB ( Primitive minX, Primitive maxX, Primitive minY, Primitive maxY ) : void

The physics engine AABB (axis-aligned bounding box). The units are the engine units of m. A Reset is required after setting. It is not recommended to change this.

SetAngle ( Primitive shapeName, Primitive angle ) : void

Reset the angle of rotation for a shape.

SetBoundaries ( Primitive left, Primitive right, Primitive top, Primitive bottom ) : void

Set solid boundaries (positioning a boundary outside the GraphicsWindow removes it).

SetBullet ( Primitive shapeName ) : void

Set a shape as a bullet. This prevents 'tunnelling' of fast moving small objects at the expense of performance.

SetDamping ( Primitive shapeName, Primitive linear, Primitive angular ) : void

Set a damping factor for a shape (default 0).

SetForce ( Primitive shapeName, Primitive forceX, Primitive forceY ) : void

Set a force to apply to a shape (Remember F = ma).

SetGravity ( Primitive gravX, Primitive gravY ) : void

Set the gravity direction and magnitude (default 0,100).

SetGroup ( Primitive shapeName, Primitive group, Primitive mask ) : void

Control which sprites interact (collide) with other shapes.

SetImpulse ( Primitive shapeName, Primitive impulseX, Primitive impulseY ) : void

Set an impulse to a shape (a kick).

SetJointMotor ( Primitive jointName, Primitive speed, Primitive maxForce ) : void

Set a motor for selected joints (Line, Prismatic_H, Prismatic_V and Revolute).

SetPosition ( Primitive shapeName, Primitive posX, Primitive posY, Primitive angle ) : void

Reset shape position.

SetRotation ( Primitive shapeName, Primitive rotation ) : void

Set shape rotation speed.

SetShapeGravity ( Primitive shapeName, Primitive gravX, Primitive gravY ) : void

Set the gravity direction and magnitude for an individual shape (default 0,100).

SetTire ( Primitive shapeName ) : void

Set an object to act as a drivable tire for a top down game. Usually gravity will be 0 and the shape should already be added to the engine. The object should be initially positioned facing forward up on the display.

SetTireProperties ( Primitive shapeName, Primitive properties ) : void

Set tire properties, they include: AntiSkid (higher value reduces skid) Drag (higher value increases forward/backward drag) Brake (higher value increases braking power) Straighten (higher value restores stearing more quickly) BrakeStraighten (higher value restores stearing more quickly while braking)

SetTorque ( Primitive shapeName, Primitive torque ) : void

Set a torque to a shape (a rotational kick).

SetVelocity ( Primitive shapeName, Primitive velX, Primitive velY ) : void

Set the velocity of a shape.

TimestepControl ( Primitive timestep, Primitive velocityIterations, Primitive positionIterations ) : void

Modify default timestep control parameters - also can be set using individual parameters.

ToggleMoving ( Primitive shapeName ) : void

Toggle a moving shape to be fixed and vice-versa. This method also sets the rotation to be on or off to match if it is moving or fixed.

ToggleRotation ( Primitive shapeName ) : void

Toggle a shape to not rotate and vice-versa. This method toggles the rotation property for fixed and moving shapes.

ToggleSensor ( Primitive shapeName ) : void

Toggle a shape to act as a sensor and vice-versa. A sensor shape does not interact with other shapes, but still provides collision data.

TurnTire ( Primitive shapeName, Primitive torque ) : void

Turn a tire shape, steer left or right.

UngroupShapes ( Primitive shape1, Primitive shape2 ) : void

Remove shape group pairing.

UnsetBullet ( Primitive shapeName ) : void

Unset a shape as a bullet. This reverts the shape to normal collision detection.

WakeAll ( ) : void

Wake all sleeping shapes - shapes sleep due to no applied forces or contacts. They wake automatically on any contact or applied force, so this action is rarely required.

WriteJson ( Primitive fileName ) : void

Write out a json script compatible with R.U.B.E. from current LDPhysics model. See https://www.iforce2d.net/rube for more details.

Приватные методы

Метод Описание
Cast ( double value, bool reverseY ) : Primitive
GetJointName ( JsonJoint joint ) : string

Описание методов

AddChain() публичный статический Метод

Add a chain between two existing shapes.
public static AddChain ( Primitive shape1, Primitive shape2 ) : Primitive
shape1 Primitive /// First shape. ///
shape2 Primitive /// Second shape. ///
Результат Primitive

AddExplosion() публичный статический Метод

Make an explosion, which consists of 50x20kg particles blast apart over 500ms.
public static AddExplosion ( Primitive posX, Primitive posY, Primitive power, Primitive damping, Primitive colour ) : void
posX Primitive The X coordinate of the explosion.
posY Primitive The Y coordinate of the explosion.
power Primitive The explosion force, this is the initial velocity of the blast particles.
damping Primitive A damping for the blast, the smaller this value the larger the blast range (default 10).
colour Primitive An optional colour of the explosion particles ("" for none).
Результат void

AddFixedAnchor() публичный статический Метод

Add a new small, transparent shape to be used as a fixed anchor point.
public static AddFixedAnchor ( Primitive posX, Primitive posY ) : Primitive
posX Primitive /// The X coordinate of the anchor. ///
posY Primitive /// The Y coordinate of the anchor. ///
Результат Primitive

AddFixedShape() публичный статический Метод

Add an existing SmallBasic shape to the physics engine as a fixed (non-dynamic) shape with friction and restitution that affects shapes that hit it.
public static AddFixedShape ( Primitive shapeName, Primitive friction, Primitive restitution ) : void
shapeName Primitive /// The name of the shape. ///
friction Primitive /// The shape friction (usually 0 to 1). ///
restitution Primitive /// The shape restitution or bounciness (usually 0 to 1). ///
Результат void

AddInactiveShape() публичный статический Метод

Add an existing SmallBasic shape to the physics engine as an inactive (non-dynamic and non-interacting) shape which only moves with the PanView method.
public static AddInactiveShape ( Primitive shapeName ) : void
shapeName Primitive /// The name of the shape. ///
Результат void

AddMovingAnchor() публичный статический Метод

Add a new small, transparent and high density shape to be used as a moving anchor point.
public static AddMovingAnchor ( Primitive posX, Primitive posY ) : Primitive
posX Primitive /// The X coordinate of the anchor. ///
posY Primitive /// The Y coordinate of the anchor. ///
Результат Primitive

AddMovingShape() публичный статический Метод

Add an existing SmallBasic shape to the physics engine as a moving (dynamic) shape.
public static AddMovingShape ( Primitive shapeName, Primitive friction, Primitive restitution, Primitive density ) : void
shapeName Primitive /// The name of the shape. ///
friction Primitive /// The shape friction (usually 0 to 1). ///
restitution Primitive /// The shape restitution or bounciness (usually 0 to 1). /// If a negative value is set for restitution, then the shape will be added with a very small size which may be used to add an inactive image that can be grouped within an irregular compound shape that matches the image boundary. ///
density Primitive /// The shape density (default 1). ///
Результат void

AddRope() публичный статический Метод

Add a rope between two existing shapes.
public static AddRope ( Primitive shape1, Primitive shape2 ) : Primitive
shape1 Primitive /// First shape. ///
shape2 Primitive /// Second shape. ///
Результат Primitive

AttachShapes() публичный статический Метод

Connect two shapes to move together as one. The shapes are connected with a distance joint and may wobble a bit if they are hit.
public static AttachShapes ( Primitive shape1, Primitive shape2 ) : void
shape1 Primitive /// The first shape name. ///
shape2 Primitive /// The second shape name. ///
Результат void

AttachShapesWithJoint() публичный статический Метод

Connect two shapes to move together as one with one of several joint types. These can be advanced and require reference to Box2D manual. In many cases it is best to prevent shape rotation for the joints to behave as desired. Multiple joints may also be applied to shapes. The methods use the initial shape positions, so set these first.
public static AttachShapesWithJoint ( Primitive shape1, Primitive shape2, Primitive type, Primitive collide, Primitive parameters ) : Primitive
shape1 Primitive The first shape name.
shape2 Primitive The second shape name.
type Primitive One of the following joint types. /// /// "Distance" - maintain a fixed distance between the shapes. /// "Gear" - link Prismatic or Revolute joints (previously created) of 2 shapes. /// "Line" - move the shapes along a line initially connecting the shapes. /// "Mouse" - move the shape to follow the mouse (both shape names should be the same). /// "Prismatic_H" - move shapes vertically along a line between the two shapes. /// "Prismatic_V" - move shapes horizontally along a line between the two shapes. /// "Pulley" - a pulley system, one shape moves up as the other moves down - position the shapes initially at the extreme points of the pulley motion. /// "Revolute" - the shapes can rotate about each other. ///
collide Primitive The connected shapes can interact with each other "True" or "False" (default). ///
parameters Primitive Optional parameters (default ""), multiple parameters are in an array. /// /// "Distance" - damping ratio (default 0) /// "Gear" - gear ratio, first joint, second joint (default 1, auto detect joints) /// "Line" - X direction, Y direction, lower translation, upper translation (default line connecting shapes, no limits) /// "Mouse" - max acceleration, damping ratio (default 10000, 0.7) /// "Prismatic_H" - X direction, Y direction, lower translation, upper translation (default 1,0, no limits) /// "Prismatic_V" - X direction, Y direction, lower translation, upper translation (default 0,1, no limits) /// "Pulley" - pulley ratio (block and tackle) (default 1) /// "Revolute" - lower angle, upper angle (default no limits) ///
Результат Primitive

AttachShapesWithRotation() публичный статический Метод

Connect two shapes to move together as one, but allow the shapes to rotate about each other.
public static AttachShapesWithRotation ( Primitive shape1, Primitive shape2 ) : void
shape1 Primitive /// The first shape name. ///
shape2 Primitive /// The second shape name. ///
Результат void

BoxShape() публичный статический Метод

Set a shape to remain within a box within the view. This is similar to PanView, except that the view pans automatically to keep the specified shape within a box region of the GraphicsWindow. Only one shape can be boxed. To unset shape box, set the shapeName to "".
public static BoxShape ( Primitive shapeName, Primitive x1, Primitive y1, Primitive x2, Primitive y2 ) : void
shapeName Primitive The shape to box or "".
x1 Primitive The left x coordinate of the box.
y1 Primitive The top y coordinate of the box.
x2 Primitive The right x coordinate of the box.
y2 Primitive The bottom y coordinate of the box.
Результат void

BrakeTire() публичный статический Метод

Apply a brake to a tire shape.
public static BrakeTire ( Primitive shapeName ) : void
shapeName Primitive The tire shape to brake.
Результат void

DetachJoint() публичный статический Метод

Disconnect two shapes that were previously joined with a joint.
public static DetachJoint ( Primitive jointName ) : void
jointName Primitive /// The joint name. ///
Результат void

DetachShapes() публичный статический Метод

Disconnect two shapes that were previously attached.
public static DetachShapes ( Primitive shape1, Primitive shape2 ) : void
shape1 Primitive /// The first shape name. ///
shape2 Primitive /// The second shape name. ///
Результат void

DisconnectShape() публичный статический Метод

Disconnect shape from the physics engine without deleting the shape.
public static DisconnectShape ( Primitive shapeName ) : void
shapeName Primitive /// The shape name. ///
Результат void

DoTimestep() публичный статический Метод

Perform a time-step update.
public static DoTimestep ( ) : void
Результат void

FollowShapeX() публичный статический Метод

Set a shape to remain stationary at X position in the view. This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual X location. Only one shape can be followed in X direction. To unset shape following, set the shapeName to "".
public static FollowShapeX ( Primitive shapeName ) : void
shapeName Primitive /// The shape to follow or "". ///
Результат void

FollowShapeY() публичный статический Метод

Set a shape to remain stationary at Y position in the view. This is similar to PanView, except that the view pans automatically to keep the specified shape at a constant visual Y location. Only one shape can be followed in Y direction. To unset shape following, set the shapeName to "".
public static FollowShapeY ( Primitive shapeName ) : void
shapeName Primitive /// The shape to follow or "". ///
Результат void

GetAllShapesAt() публичный статический Метод

Get an array of all the physics engine shapes (if any) at the input coordinates. The coordinates for this method are the physics engine coordinates if panning is present.
public static GetAllShapesAt ( Primitive posX, Primitive posY ) : Primitive
posX Primitive /// The X coordinate. ///
posY Primitive /// The Y coordinate. ///
Результат Primitive

GetAngle() публичный статический Метод

Get the angle of rotation for the shape.
public static GetAngle ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GetCollisions() публичный статический Метод

Get an array of all the shapes that the specified shape collided with during the last DoTimestep().
public static GetCollisions ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape to check for collisions. ///
Результат Primitive

GetContacts() публичный статический Метод

Get a list of shapes that collided within a distance of a specified contact point.
public static GetContacts ( Primitive posX, Primitive posY, Primitive distance ) : Primitive
posX Primitive /// The X coordinate of a contact position to check. ///
posY Primitive /// The Y coordinate of a contact position to check. ///
distance Primitive /// A maximum distance from the contact point for the contact. ///
Результат Primitive

GetInertia() публичный статический Метод

Get the moment of inertia of a shape.
public static GetInertia ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GetMass() публичный статический Метод

Get the mass of a shape.
public static GetMass ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GetPan() публичный статический Метод

Get the current pan offset, see PanView, FollowShapeX(Y) and BoxShape. World coordinates = screen coordinates + pan offset.
public static GetPan ( ) : Primitive
Результат Primitive

GetPosition() публичный статический Метод

Get the centre of the shape coordinates.
public static GetPosition ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GetRotation() публичный статический Метод

Get the shape rotation speed.
public static GetRotation ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GetShapeAt() публичный статический Метод

Get the shape (if any) at the input coordinates. The coordinates for this method are the screen coordinates if panning is present.
public static GetShapeAt ( Primitive posX, Primitive posY ) : Primitive
posX Primitive /// The X coordinate. ///
posY Primitive /// The Y coordinate. ///
Результат Primitive

GetTireInformation() публичный статический Метод

Get tire information, it includes: Skid (if this value exceeds the property AntiSkid, then the tire is skidding) Crash (the value is the speed of the impact)
public static GetTireInformation ( Primitive shapeName ) : Primitive
shapeName Primitive The tire shape.
Результат Primitive

GetTireProperties() публичный статический Метод

Get tire properties, they include: AntiSkid (higher value reduces skid) Drag (higher value increases forward/backward drag) Brake (higher value increases braking power) Straighten (higher value restores steering more quickly) BrakeStraighten (higher value restores steering more quickly while braking)
public static GetTireProperties ( Primitive shapeName ) : Primitive
shapeName Primitive The tire shape.
Результат Primitive

GetVelocity() публичный статический Метод

Get the velocity of the shape.
public static GetVelocity ( Primitive shapeName ) : Primitive
shapeName Primitive /// The shape name. ///
Результат Primitive

GroupShapes() публичный статический Метод

Solidly group two shapes to move together as one. Shape1 is added to shape2 to act as one shape.
public static GroupShapes ( Primitive shape1, Primitive shape2 ) : void
shape1 Primitive /// The first shape name. ///
shape2 Primitive /// The second shape name. ///
Результат void

Help() публичный статический Метод

This function is just to display this help. The extension uses Box2D (http://box2d.org) as an engine and provides an interface between it and the graphics capabilities of SmallBasic. Only shapes that are connected to the physics engine take part in the motion physics, for example you may add normal shapes (e.g. a gun and not connect it to the physics engine). Once a shape is connected to the engine, it is best to only interact with it through the methods provided by the extension. All positions are in the SmallBasic GraphicsWindow pixels and refer to shape centres. Image and text shapes are treated as rectangles, and ellipses as circles; there is also triangle and convex polygon support, but not lines. Images may be treated as circles by setting the property LoadImagesAsCircles to "True". One issue that Box2D has difficulty with is small fast moving objects that can 'tunnel' through other shapes without being deflected (see the SetBullet option). Another problem is shapes of very different size and hence mass, especially large shapes when they are connected together. It may be necessary to modify the density for these (the Anchor options are an attempt to automate this a bit), otherwise the default density of 1 is good. Resist the temptation to connect too many shapes together. It may be possible to improve the stability of some 'difficult' models using the TimestepControl settings, but the defaults look good for most cases. Do not call the physics methods inside SmallBasic event subroutines directly, rather set flags that can be processed in a main game loop. There are sample SmallBasic programs and a Getting Started Guide that comes with the extension dll - this is the best place to start. Report bugs and problems to the SmallBasic forum (http://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads), but first simplify your SmallBasic code to isolate the issue before providing a short 'runnable' code sample.
public static Help ( ) : void
Результат void

MoveTire() публичный статический Метод

Move a tire shape, apply a forward or backward force.
public static MoveTire ( Primitive shapeName, Primitive force ) : void
shapeName Primitive The tire shape to move.
force Primitive The force to apply, positive is forward, negative is backward.
Результат void

PanView() публичный статический Метод

Pan the camera view, including window boundaries.
public static PanView ( Primitive panHorizontal, Primitive panVertical ) : void
panHorizontal Primitive /// Pan in the horizontal direction (negative is left). ///
panVertical Primitive /// Pan in the vertical direction (negative is up). ///
Результат void

RayCast() публичный статический Метод

Cast an invisible ray to detect the proximity of shapes.
public static RayCast ( Primitive shapeName, Primitive angle, Primitive distance ) : Primitive
shapeName Primitive The shape to cast the ray from.
angle Primitive The angle in degrees to check, this can also be an array of angles.
distance Primitive A maximum distance to check.
Результат Primitive

ReadJson() публичный статический Метод

Read in a json script compatible with R.U.B.E. and create a LDPhysics model. See https://www.iforce2d.net/rube for more details.
public static ReadJson ( Primitive fileName, Primitive scale, Primitive reverseY, Primitive stationary, Primitive offsetX, Primitive offsetY ) : Primitive
fileName Primitive The full path to the json file to read.
scale Primitive Scale all shapes, default 1 (no scaling).
reverseY Primitive Reverse the Y direction up to down ("True" or "False").
stationary Primitive Set all shapes to be initially at rest, joint motors are still enabled ("True" or "False").
offsetX Primitive Add an x coordinate offset to all shapes.
offsetY Primitive Add a y coordinate offset to all shapes, especially useful when reverseY is set.
Результат Primitive

RemoveChain() публичный статический Метод

Remove a chain.
public static RemoveChain ( Primitive shapeName ) : void
shapeName Primitive /// The chain name. ///
Результат void

RemoveFrozen() публичный статический Метод

Removes all frozen shapes - outside the AABB for the engine.
public static RemoveFrozen ( ) : void
Результат void

RemoveRope() публичный статический Метод

Remove a rope.
public static RemoveRope ( Primitive shapeName ) : void
shapeName Primitive /// The rope name. ///
Результат void

RemoveShape() публичный статический Метод

Remove a shape.
public static RemoveShape ( Primitive shapeName ) : void
shapeName Primitive /// The name of the shape. ///
Результат void

Reset() публичный статический Метод

Reset (delete all physics engine attached shapes).
public static Reset ( ) : void
Результат void

SetAABB() публичный статический Метод

The physics engine AABB (axis-aligned bounding box). The units are the engine units of m. A Reset is required after setting. It is not recommended to change this.
public static SetAABB ( Primitive minX, Primitive maxX, Primitive minY, Primitive maxY ) : void
minX Primitive /// The left coordinate of the universe (default -100). ///
maxX Primitive /// The right coordinate of the universe (default 200). ///
minY Primitive /// The top coordinate of the universe (default -100). ///
maxY Primitive /// The bottom coordinate of the universe (default 200). ///
Результат void

SetAngle() публичный статический Метод

Reset the angle of rotation for a shape.
public static SetAngle ( Primitive shapeName, Primitive angle ) : void
shapeName Primitive /// The shape name. ///
angle Primitive /// The angle of rotation in degrees. ///
Результат void

SetBoundaries() публичный статический Метод

Set solid boundaries (positioning a boundary outside the GraphicsWindow removes it).
public static SetBoundaries ( Primitive left, Primitive right, Primitive top, Primitive bottom ) : void
left Primitive /// The left boundary X value. ///
right Primitive /// The right boundary X value. ///
top Primitive /// The top boundary Y value. ///
bottom Primitive /// The bottom (ground) boundary Y value. ///
Результат void

SetBullet() публичный статический Метод

Set a shape as a bullet. This prevents 'tunnelling' of fast moving small objects at the expense of performance.
public static SetBullet ( Primitive shapeName ) : void
shapeName Primitive /// The shape name. ///
Результат void

SetDamping() публичный статический Метод

Set a damping factor for a shape (default 0).
public static SetDamping ( Primitive shapeName, Primitive linear, Primitive angular ) : void
shapeName Primitive /// The shape to modify. ///
linear Primitive /// Linear damping factor. ///
angular Primitive /// Angular damping factor. ///
Результат void

SetForce() публичный статический Метод

Set a force to apply to a shape (Remember F = ma).
public static SetForce ( Primitive shapeName, Primitive forceX, Primitive forceY ) : void
shapeName Primitive /// The shape to modify. ///
forceX Primitive /// X component of the force. ///
forceY Primitive /// Y component of the force. ///
Результат void

SetGravity() публичный статический Метод

Set the gravity direction and magnitude (default 0,100).
public static SetGravity ( Primitive gravX, Primitive gravY ) : void
gravX Primitive /// The X component of gravity. ///
gravY Primitive /// The Y component of gravity. ///
Результат void

SetGroup() публичный статический Метод

Control which sprites interact (collide) with other shapes.
public static SetGroup ( Primitive shapeName, Primitive group, Primitive mask ) : void
shapeName Primitive /// The shape to modify. ///
group Primitive /// The group that the current shape belongs to (default 0). This should be an integer between 0 and 15. ///
mask Primitive /// An array of groups that this shape will collide with (default all groups 0,1,2,..,14,15). /// To allow the shape to only interact with groups 0, 1 and 4 would be "1=0;2=1;3=4;". ///
Результат void

SetImpulse() публичный статический Метод

Set an impulse to a shape (a kick).
public static SetImpulse ( Primitive shapeName, Primitive impulseX, Primitive impulseY ) : void
shapeName Primitive /// The shape to modify. ///
impulseX Primitive /// X component of the impulse. ///
impulseY Primitive /// Y component of the impulse. ///
Результат void

SetJointMotor() публичный статический Метод

Set a motor for selected joints (Line, Prismatic_H, Prismatic_V and Revolute).
public static SetJointMotor ( Primitive jointName, Primitive speed, Primitive maxForce ) : void
jointName Primitive /// The joint name. ///
speed Primitive The desired motor speed.
maxForce Primitive The maximum motor force (torque for Revolute). /// A zero value turns motor off.
Результат void

SetPosition() публичный статический Метод

Reset shape position.
public static SetPosition ( Primitive shapeName, Primitive posX, Primitive posY, Primitive angle ) : void
shapeName Primitive /// The shape to modify. ///
posX Primitive /// X component shape centre. ///
posY Primitive /// Y component shape centre. ///
angle Primitive /// The angle of rotation in degrees. ///
Результат void

SetRotation() публичный статический Метод

Set shape rotation speed.
public static SetRotation ( Primitive shapeName, Primitive rotation ) : void
shapeName Primitive /// The shape to modify. ///
rotation Primitive /// The angular rotation speed degrees/s. ///
Результат void

SetShapeGravity() публичный статический Метод

Set the gravity direction and magnitude for an individual shape (default 0,100).
public static SetShapeGravity ( Primitive shapeName, Primitive gravX, Primitive gravY ) : void
shapeName Primitive /// The shape to modify. ///
gravX Primitive /// The X component of gravity. ///
gravY Primitive /// The Y component of gravity. ///
Результат void

SetTire() публичный статический Метод

Set an object to act as a drivable tire for a top down game. Usually gravity will be 0 and the shape should already be added to the engine. The object should be initially positioned facing forward up on the display.
public static SetTire ( Primitive shapeName ) : void
shapeName Primitive The shape to make a tire.
Результат void

SetTireProperties() публичный статический Метод

Set tire properties, they include: AntiSkid (higher value reduces skid) Drag (higher value increases forward/backward drag) Brake (higher value increases braking power) Straighten (higher value restores stearing more quickly) BrakeStraighten (higher value restores stearing more quickly while braking)
public static SetTireProperties ( Primitive shapeName, Primitive properties ) : void
shapeName Primitive The tire shape.
properties Primitive An array of one or more properties to set. /// The index is one of the properties (case sensitive) and the value is the property value.
Результат void

SetTorque() публичный статический Метод

Set a torque to a shape (a rotational kick).
public static SetTorque ( Primitive shapeName, Primitive torque ) : void
shapeName Primitive /// The shape to modify. ///
torque Primitive /// The torque to apply. ///
Результат void

SetVelocity() публичный статический Метод

Set the velocity of a shape.
public static SetVelocity ( Primitive shapeName, Primitive velX, Primitive velY ) : void
shapeName Primitive /// The shape to modify. ///
velX Primitive /// X component of the velocity. ///
velY Primitive /// Y component of the velocity. ///
Результат void

TimestepControl() публичный статический Метод

Modify default timestep control parameters - also can be set using individual parameters.
public static TimestepControl ( Primitive timestep, Primitive velocityIterations, Primitive positionIterations ) : void
timestep Primitive /// Time-step (default 0.025). ///
velocityIterations Primitive /// Velocity iterations (default 6). ///
positionIterations Primitive /// Position iterations (default 2). ///
Результат void

ToggleMoving() публичный статический Метод

Toggle a moving shape to be fixed and vice-versa. This method also sets the rotation to be on or off to match if it is moving or fixed.
public static ToggleMoving ( Primitive shapeName ) : void
shapeName Primitive The shape name.
Результат void

ToggleRotation() публичный статический Метод

Toggle a shape to not rotate and vice-versa. This method toggles the rotation property for fixed and moving shapes.
public static ToggleRotation ( Primitive shapeName ) : void
shapeName Primitive The shape name.
Результат void

ToggleSensor() публичный статический Метод

Toggle a shape to act as a sensor and vice-versa. A sensor shape does not interact with other shapes, but still provides collision data.
public static ToggleSensor ( Primitive shapeName ) : void
shapeName Primitive The shape name.
Результат void

TurnTire() публичный статический Метод

Turn a tire shape, steer left or right.
public static TurnTire ( Primitive shapeName, Primitive torque ) : void
shapeName Primitive The tire shape to turn.
torque Primitive The torque, rotation force to apply, positive is turn right, negative is turn left.
Результат void

UngroupShapes() публичный статический Метод

Remove shape group pairing.
public static UngroupShapes ( Primitive shape1, Primitive shape2 ) : void
shape1 Primitive /// The first shape name. ///
shape2 Primitive /// The second shape name. ///
Результат void

UnsetBullet() публичный статический Метод

Unset a shape as a bullet. This reverts the shape to normal collision detection.
public static UnsetBullet ( Primitive shapeName ) : void
shapeName Primitive /// The shape name. ///
Результат void

WakeAll() публичный статический Метод

Wake all sleeping shapes - shapes sleep due to no applied forces or contacts. They wake automatically on any contact or applied force, so this action is rarely required.
public static WakeAll ( ) : void
Результат void

WriteJson() публичный статический Метод

Write out a json script compatible with R.U.B.E. from current LDPhysics model. See https://www.iforce2d.net/rube for more details.
public static WriteJson ( Primitive fileName ) : void
fileName Primitive The full path to the json file to create.
Результат void