Click or drag to resize
SpriteBaseSnapToGround Method
Ensure the sprite stays in contact with the ground by altering its velocity to snap down onto the ground when it is close to the ground.

Namespace: (Default Namespace)
Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax
C#
public virtual bool SnapToGround(
	int Threshhold
)

Parameters

Threshhold
Type: SystemInt32
The number of pixels that mey separate the sprite from the ground. If the sprite is within this threshhold distance, it will be "snapped".

Return Value

Type: Boolean
True if the sprite was snapped to the ground.
Remarks
Note that this does not actually move the sprite, but rather just alters its velocity so that when MoveByVelocity is applied, it will be touching the ground, if the appropriate conditions are met. The purpose of this rule is to help sprites behave as desired when going downhill in case the force of gravity isn't enough to keep them "grounded" (which it often isn't with the simple physics model used for sprites).
See Also