SpriteLibrary
SpriteLibrary
SpriteLibrary
Sprite Class
Sprite Methods
AddAnimation Method
AnimateJustAFewTimes Method
AnimateOnce Method
CancelMoveTo Method
ChangeAnimation Method
ChangeAnimationSpeed Method
ChangeFrameAnimationSpeed Method
CheckSpriteHitsSprite Method
ConvertDegreesToRadians Method
ConvertRadiansToDegrees Method
Destroy Method
GetAnimationSpeed Method
GetFrameAnimationSpeed Method
GetImage Method
GetSpriteBaseImageCenter Method
GetSpriteDegrees Method
GetSpritePictureboxCenter Method
GetSpriteRadans Method
GetSpriteVector Method
HideSprite Method
IsPaused Method
MoveTo Method
Pause Method
PutBaseImageLocation Method
PutPictureBoxLocation Method
RecalcPictureBoxLocation Method
ReplaceImage Method
ReturnAdjustmentRatio Method
SendToBack Method
SendToFront Method
SetName Method
SetSize Method
SetSpriteDirection Method
SetSpriteDirectionDegrees Method
SetSpriteDirectionRadians Method
SetSpriteDirectionToPoint Method
SpriteAdjustedPoint Method
SpriteAtImagePoint Method
SpriteAtPictureBoxPoint Method
SpriteCanMoveOnImage Method
SpriteCanMoveOnPictureBox Method
SpriteIntersectsRectangle Method
UnhideSprite Method
UnPause Method

# Sprite SetName Method

Give this sprite a name. This way we can make a duplicate of it by specifying the name. The idea behind sprites is that you want to be able to have multiple of the same things (for most sprites). For example, you want to make an asteroid Sprite, and then send twenty of them bouncing around on the screen.

The best way to do this is to create a "Named Sprite", which you use as a template. From that point onward, you create a duplicate of that sprite. So the Named Sprite never gets used, it sits there as something that gets duplicated every time you want one. DuplicateSprite(String) is the function you usually use to duplicate a sprite.

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public void SetName(
    	string Name
    )

#### Parameters

Name
  Type: System
  String
  A string that represents the new name of the sprite

Examples
Give this sprite a name. This way we can make a duplicate of it by specifying the name. The idea behind sprites is that you want to be able to have multiple of the same things (for most sprites). For example, you want to make an asteroid Sprite, and then send twenty of them bouncing around on the screen.

The best way to do this is to create a "Named Sprite", which you use as a template. From that point onward, you create a duplicate of that sprite. So the Named Sprite never gets used, it sits there as something that gets duplicated every time you want one. DuplicateSprite(String) is the function you usually use to duplicate a sprite.

This example shows how we create a "Named Sprite", which we do not put on the screen. But instead, we make a duplicate of the sprite, which we send shooting off to destroy the enemy. This example is a little misleading. You only need to create the Named Sprite once. From that point in time, you can duplicate the Named Sprite to get another copy of it.
C#
Copy

    Sprite MissileSprite = new Sprite(new Point(0, 300), MySpriteController, Properties.Resources.missiles, 100, 100, 220, 4);
    MissileSprite.SetName("Missile");
    MissileSprite.SetSize(new Size(50,50));

    Sprite NewSprite = MySpriteController.DuplicateSprite("Missile");
    NewSprite.AutomaticallyMoves = true;
    NewSprite.PutBaseImageLocation(new Point(startx, starty));
    NewSprite.MoveTo(TargetSprite);
    NewSprite.MovementSpeed = speed;

There are two related concepts. You may want to read up on LinkControllersForSpriteTemplateSharing(SpriteController) to let multiple SpriteControllers look up named Sprites from each-other. You can also read up on the SpriteDatabase, which allows you to define NamedSprites in a database; the SpriteControllers can access the database instead of needing to do an initial "new Sprite(....);" to create your Sprite Template.
See Also

#### Reference

Sprite Class
SpriteLibrary Namespace