Click or drag to resize
PlanBaseCheckNextCoordinate Method
Make a sprite move toward the next coordinate in the plan when appropriate.

Namespace: (Default Namespace)
Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax
C#
public virtual int CheckNextCoordinate(
	SpriteBase Sprite,
	int CoordinateIndex,
	ref int WaitCounter
)

Parameters

Sprite
Type: (Default Namespace)SpriteBase
Sprite that is following coordinates in this plan
CoordinateIndex
Type: SystemInt32
Zero-based index of the coordinate within the plan toward which the sprite is currently heading.
WaitCounter
Type: SystemInt32
A variable that is used to count frames while this sprite is waiting at a coordinate for a time period specified by the coordinate's weight to elapse.

Return Value

Type: Int32
The index of the coordinate toward which the sprite should be heading.
Remarks

This function determines if the sprite should head toward the next coordinate by checking if the sprite is within this plan's TargetDistance of the specified coordinate. If it is, then it checks the coordinate's weight, to see if the sprite is supposed to wait at this coordinate. If it's not supposed to wait, the function returns the next coordinate index right away. If it is supposed to wait, the function will only return the next coordinate index if the sprite has waited the specified number of frames at the current coordinate.

Normally two sprite parameters are used in conjunction with a sprite that follows a series of coordinates in a plan, and they are both passed into this function. One parameter tracks the index of the coordinate toward which the the sprite is currently heading. The other tracks how long the sprite has waited at the current coordinate. The coordinate parameter is passed in as the the input for CoordinateIndex and also specified to receive the output of the function. The wait counter is passed for the last parameter and is automatically updated when needed because it is passed by reference.

Examples
This example demonstrates the common usage of this function on a sprite named "Plasma 1".
m_ParentLayer.m_Plasma_1.CoordIndex = CheckNextCoordinate(m_ParentLayer.m_Plasma_1, m_ParentLayer.m_Plasma_1.CoordIndex, ref m_ParentLayer.m_Plasma_1.WaitCounter);
For a more complete example, see StopSprite(SpriteBase).
See Also