Click or drag to resize

SpriteControllerDuplicateSprite Method (String)

Find a sprite that has been named with the specified name. Then duplicate that sprite. If you have SpriteControllers which are linked (see SpriteController.LinkControllersForSpriteTemplateSharing for how to do this), if the Sprite template is not contained in this controller, it is looked up in any linked controllers.

Namespace:  SpriteLibrary
Assembly:  SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
public Sprite DuplicateSprite(
	string Name
)

Parameters

Name
Type: SystemString
The name of a sprite

Return Value

Type: Sprite
A duplicate of the specified sprite. It has no location, and does not retain the sprite name.
Examples
Below is a function that creates a sprite based off a name, and puts it at the designated coordinates.
C#
public void AddSprite(string name, int startx, int starty)
{
     Sprite NewSprite = MySpriteController.DuplicateSprite(What.ToString());
     if(NewSprite != null)
     {
         NewSprite.AutomaticallyMoves = true;
         NewSprite.CannotMoveOutsideBox = true;
         NewSprite.SetSpriteDirectionDegrees(180); //left
         NewSprite.PutBaseImageLocation(new Point(startx, starty));
         NewSprite.MovementSpeed = 5;
     }
}
See Also