SpriteLibrary

# SpriteLibrary Namespace

SpriteLibrary is a .net graphical library for creating and controlling sprites on a PictureBox. A sprite is an animated image that can be moved around on a picturebox. You can give the sprite an initial location, and either move it around manually or give it specific movement controls. To use this library, you will need to add a reference to it in your project. You will also need a reference to "Windows Base." In the solution explorer, if you right-click your project and go to "add", and then "reference" and click "WindowsBase" towards the bottom. On that same window, on the left, click "browse." Then, click the "Browse..." button and find the sprite-library dll. The main places to find the SpriteLibrary and sample programs using this SpriteLibrary are here: http://www.codeproject.com/Articles/1085446/Using-Sprites-Inside-Windows-Forms and http://tyounglightsys.ddns.info/SpriteLibrary
Classes

| Class | Description
--- | --- | ---

AnimationInfo

An AnimationInfo class is used by the SpriteInfo class to contain the instructions for creating a sprite through the dictionary. Most people will not want to manually use these. It is simplest to use the SpriteDatabase.OpenEditWindow function and use the built-in sprite editor. That editor will create a file that can be used in the database without your needing to know about the AnimationInfo. Again, you do not want to use these within your program. Let the SpriteDatabase use this. The reason these are visible to the program is because This code uses "XML Serialization" to load and save. XML Serialization requires the items you are serializing to be "public", which makes them visible.

| Sprite | A Sprite is an animated image that has a size, position, rotation, and possible vector It tracks where in the animation sequence it is, can report colisions, etc. This SpriteController draws, moves, and deals with most graphical aspects of the sprites for you.
| SpriteController | A sprite controller is the main heart of the sprite class. Each SpriteController manages one picturebox. If at all possible, try to keep each game in one picturebox, and try to avoid making and destroying new forms with SpriteController/pictureboxes in them. It is hard to destroy them completely.

SpriteDatabase

Store Sprite information in a database. You can preload your database with sprite definitions, and then create the sprites as needed. This can drastically reduce the initial load time of a game or something. Though, what it really does is spread out the load time. It still takes the same amount of time to load all the sprites, it just loads them on-demand. Using a dictionary often hides any load time issues.

| SpriteEventArgs | An EventArgs that contains information about Sprites. Most of the Sprite events use this SpriteEventArgs.

SpriteInfo

A class which is used by the SpriteDatabase to build Sprites. You should not need to use this in your programming. It is simplest to use the Load/Save features of the SpriteDatabase, which will load and save the SpriteInfo. Again, you do not want to use these within your program. Let the SpriteDatabase use this. The reason these are visible to the program is because This code uses "XML Serialization" to load and save. XML Serialization requires the items you are serializing to be "public", which makes them visible.

| SpritePayload | The SpritePayload is a stub of a class, for storing user-defined data and functions along with a sprite.

Structures

| Structure | Description
--- | --- | ---
| SpriteAdjustmentRatio | A structure that contains the width and height adjustment ratio. Use this if you need to manually calculate positions between the PictureBox that the sprite is in, and the Background Image itself.

Delegates

| Delegate | Description
--- | --- | ---
| Sprite SpriteEventHandler | A delegate that has a SpriteEventArgs instead of EventArgs. Used for most of the Sprite events. This allows us to pass more information from sprite events than a basic EventArgs allows for
| SpriteKeyEventHandler | This is a delegate for a keypress event.

Enumerations

| Enumeration | Description
--- | --- | ---
| AnimationType | The SpriteInfo only recognizes a few ways to create a sprite. Here are the different ways.
| SpriteCollisionMethod | The various types of collisions a sprite can have. Currently only rectangle works. The other types were added when I thought the different types of collision types were needed. Someday we may add these if we find they are useful, or if someone else decides they want to help program the SpriteLibrary. These values are primarily used in Sprite Events
| SpritePauseType | The type of pause signals you can give a sprite or the sprite controller