Click or drag to resize

SpriteMoveTo Method (ListPoint)

Tell the sprite to move towards each point in turn. The sprite will move in a straight line until the first point. From there it moves to the next point, until it has reached the last point. Every time it reaches a point, the SpriteArrivedAtWaypoint event is triggered. When it reaches the final point in the list, the SpriteArrivedAtEndPoint event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has arrived, it is set to true.

Namespace:  SpriteLibrary
Assembly:  SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
public void MoveTo(
	List<Point> DestinationList
)

Parameters

DestinationList
Type: System.Collections.GenericListPoint
A list of Image-Points that the sprite will follow, one after the other
Examples
In this example, we are creating a missile sprite and giving it a path to follow to get where we want it to go. The path is somewhat curved. The missile will fly straight between each of the different points listed.
C#
Sprite NewSprite = MySpriteController.DuplicateSprite("Missile");
NewSprite.AutomaticallyMoves = true;
NewSprite.PutBaseImageLocation(new Point(100, 100));
List<Point> MyWaypoints = new List<Point>();
MyWaypoints.Add(new Point(100,100));
MyWaypoints.Add(new Point(120, 90));
MyWaypoints.Add(new Point(130, 80));
MyWaypoints.Add(new Point(140, 90));
MyWaypoints.Add(new Point(180,100));
NewSprite.MoveTo(TargetSprite.BaseImageLocation);
NewSprite.MovementSpeed = speed;
See Also