Click or drag to resize
Sprite Methods

The Sprite type exposes the following members.

Methods
  NameDescription
Public methodAddAnimation(Image)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAddAnimation(Image, Size)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAddAnimation(Image, Int32)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAddAnimation(Int32, Int32)
Duplicate an animation, except rotated by the specified number of degrees. For example, if you have a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that rotation to it. In the long haul, generating a few rotated animations is less memory intensive than rotating it on demand.
Public methodAddAnimation(Image, Int32, Int32)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAddAnimation(Int32, Boolean, Boolean)
Duplicate an animation, except rotated by the specified number of degrees. For example, if you have a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that rotation to it. In the long haul, generating a few rotated animations is less memory intensive than rotating it on demand using the MirrorHorizontally or MirrorVertically booleans.
Public methodAddAnimation(Image, Int32, Int32, Int32)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAddAnimation(Point, Image, Int32, Int32, Int32, Int32)
Add another animation to an existing Sprite. After you add animations, you can use ChangeAnimation to select which animation you want the specified sprite to show. For example, you may want to have Animation 0 be a guy walking left, and animation 1 is that same guy walking right. Because we do not specify the number of frames, it starts at the top-left corner and grabs as many frames as it can from the image.
Public methodAnimateJustAFewTimes
Start a new animation. It will complete the animation the number of times you specify. For example, if your sprite is walking, and one animation is one step, specifying 4 here will result in your sprite taking 4 steps and then the animation stops. You will want to make sure you are checking for when the animation stops, using the SpriteAnimationComplete event, checking the Sprite.AnimationDone flag.
Public methodAnimateOnce
Start a new animation, but do it just once. You can use AnimateJustAFewTimes(1) to the same effect. Or, you can use AnimateJustAFewTimes with a different number. The SpriteAnimationComplete event will fire off when the animation completes. The variable, Sprite.AnimationDone will be true once the animation finishes animating.
Public methodCancelMoveTo
Cancel a MoveTo command. The sprite will stop moving, and all the waypoints will be removed.
Public methodChangeAnimation
Start a new animation index from scratch
Public methodChangeAnimationSpeed
Change the animation speed of a particular animation. This looks at the first frame and compares that frame to the speed specified. It adjusts all the animations by the same percentage.
Public methodChangeFrameAnimationSpeed
Change the animation speed of a specific frame. Beware. This affects every sprite using this frame
Public methodCheckSpriteHitsSprite
Check to see if two sprites hit each-other. The sprite collision methods are not all programmed in.
Public methodConvertDegreesToRadians
Convert a number from degrees to radians.
Public methodConvertRadiansToDegrees
Convert a number from radians to degrees.
Public methodDestroy
Tell the sprite to kill itself. It will erase itself and then be removed from the spritelist. Then it will be gone forever.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAnimationSpeed
Return the animation speed of this particualar animation of the sprite.
Public methodGetFrameAnimationSpeed
Get the animation speed of a single frame.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetImage
return the current image frame. Warning: If you write to this image, it will affect all sprites using this frame.
Public methodGetImage(Int32, Int32)
return the frame for the given index. Warning: If you write to this image, it will affect all sprites using this frame.
Public methodGetSpriteBaseImageCenter
Return the centerpoint of the sprite, as found on the background image
Public methodGetSpriteDegrees
Get the direction that the sprite is traveling in in degrees. You may want to use Math.Round on the results. The value returned is usually just a tiny bit off from what you set it with. For example, if you set the sprite movement direction to be 270 degrees (down), this function may return it as 269.999992. Rounding the number will give it back to you at probably the same direction you set it as.
Public methodGetSpritePictureboxCenter
Return the centerpoint of the sprite, as found on the picturebox
Public methodGetSpriteRadans
Returns the direction the sprite is currently traveling, using Radians.
Public methodGetSpriteVector
Return the current vector that the sprite is moving along
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHideSprite
Remove the sprite from the field. This does not destroy the sprite. It simply removes it from action. Use UnhideSprite to show it again.
Public methodIsPaused
Ask if the sprite is paused using the specified sprite type (default is PauseAll)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMoveTo(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.
Public methodMoveTo(Point)
Tell the Sprite to move towards a destination. You need to give the sprite a MovementSpeed and tell the sprite that it can automatically move. But the sprite will begin a journey towards that point at the MovementSpeed you have set. When it gets to the point, the SpriteArrivedAtEndPoint event will fire off. Also, the SpriteReachedEnd bool will be true.
Public methodMoveTo(Sprite)
Move to where the destination sprite currently is at. This is a dumb move. It does not take into consideration the movement direction of the destination sprite. So the moving sprite does need to be moving a bit faster than the sprite you are trying to hit for it to do so.
Public methodPause
Pause the sprite. We can pause just the animation (and still let it move), pause movement (and let it animate), or pause everything.
Public methodPutBaseImageLocation(Point)
Put the Sprite at a specified location, using the dimentions of the BackgroundImage. Unless you are using coordinates you have gotten from a mouse-click, this is how you want to place a Sprite somewhere. It is the easiest way to track things. But, if you are doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
Public methodPutBaseImageLocation(Double, Double)
Put the Sprite at a specified location, using the dimentions of the BackgroundImage. Unless you are using coordinates you have gotten from a mouse-click, this is how you want to place a Sprite somewhere. It is the easiest way to track things. But, if you are doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
Public methodPutPictureBoxLocation
Put the Sprite at a specified location, using the dimentions of the PictureBox. You want to use this if you got your X/Y position from a mouse-click. Otherwise, this is the harder way to track things, particularly if your window can resize. Use PutBaseImageLocation instead.
Public methodRecalcPictureBoxLocation
Done when the box resizes. We need to recompute the picturebox location. The resize function automatically calls this. You should never need to do so.
Public methodReplaceImage
Replace a sprite image. It will replace the current frame unless you specify both an animation and the frame within the animation you wish to replace. Warning: This replaces the image_frame for every sprite that uses that is based off the same image.
Public methodReturnAdjustmentRatio
Taking into consideration how the sprite is stretched or shrunk, it returns a SpriteAdjustmentRatio that can be used to work with the sprite itself.
Public methodSendToBack
Make the sprite go behind all other sprites
Public methodSendToFront
Make the sprite show up in front of all other sprites.
Public methodSetName
Give this sprite a name. This way we can make a duplicate of it by specifying the name
Public methodSetSize
Resize the sprite using the base image coordinates. The width and height specified are relative to the size of the background image, not the picturebox.
Public methodSetSpriteDirection
Set the sprite direction using a vector. The vector may contain a speed as well as the movement delta (amount of x shift, and amount of y shift.) If so, this function may also affect the movement speed Most people prefer to use SetSpriteDirectionDegrees instead of using vectors.
Public methodSetSpriteDirectionDegrees
Given a "degree" (from 0 to 360, set the direction that the sprite moves automatically. 0 is right, 90 is up, 180 is left and 270 is down.
Public methodSetSpriteDirectionRadians
Set the sprite direction using Radians. Most people do not want to use this. Use SetSpriteDirectionDegrees instead unless you like math and know what you are doing with Radians.
Public methodSetSpriteDirectionToPoint
Sets the Sprite Moving towards a given point. You are responsible to do something with it once it gets there. If you want it to automatically stop upon reaching it, use MoveTo instead. Actually, the MoveTo function works a lot better than this one. Because of integer rounding and a few other things, this function is a little bit imprecise. If you send it towards a point, it will go in that general direction. The MoveTo function will perpetually recalculate its way to the destination point and actually reach that point. SetSpriteDirectionToPoint will sort-of head in the direction of the point. But MoveTo will go to that point.
Public methodSpriteAdjustedPoint
Because sprites are scaled (shrunk or stretched), this function finds the point within the sprite that is specified by the location. this function is used by a number of internal processes, but may be useful to you. But probably not.
Public methodSpriteAtImagePoint
Check to see if the sprite exists at the point specified. The point given is in coordinates used by the image (not the PictureBox, use SpriteAtPictureBox for that)
Public methodSpriteAtPictureBoxPoint
Return true or false, asking if the specifiec sprite is at the point on the picturebox. You can use this with a mouse-click to see if you are clicking on a sprite. Use the SpriteCollisionMethod "transparent" to see if you have clicked on an actual pixel of the sprite instead of just within the sprite rectangle.
Public methodSpriteCanMoveOnImage
Return true if the sprite can go to this point and still be on the drawing-board.
Public methodSpriteCanMoveOnPictureBox
Return true if the sprite can go to this point and still be on the drawing-board.
Public methodSpriteIntersectsRectangle
Check to see if the specified rectangle overlaps with the sprite.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnhideSprite
Make the sprite reappear. If you have not positioned it yet, it will show up at the top corner. It is best to only use this when you have hidden it using HideSprite
Public methodUnPause
unpause the sprite.
Top
See Also