Click or drag to resize
SpriteBasePushSpriteIntoView Method
Alter this sprite's velocity so that it remains within the map's visible area or within the scroll margins, according to this sprite's layer's position within the map.

Namespace: (Default Namespace)
Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax
C#
public virtual void PushSpriteIntoView(
	bool StayInScrollMargins
)

Parameters

StayInScrollMargins
Type: SystemBoolean
If true, the sprite will be pushed toward the center as soon as it comes within a minimum distance of the edge of the display, determined by the map's scroll margins (ScrollMarginLeft, ScrollMarginTop, ScrollMarginRight, ScrollMarginBottom). Otherwise the sprite will only be pushed when it reaches the edge of the display.
Remarks
This takes into account the sprites LocalDX and LocalDY properties in case it is riding another sprite. If the sprite has somehow gone far off the edge of the map, it's velocity may be set to unreasonable values because it will attempt to enter the display in a single frame. This function will only set the velocity, not actually move the sprite (MoveByVelocity is used to move sprites). This allows you to make the sprite react to many forces before moving it. In a multi-player game with two players in the same view this is useful for ensuring that both players remain on screen.
See Also