SpriteLibrary
SpriteLibrary
SpriteLibrary
AnimationInfo Class
AnimationType Enumeration
Sprite Class
Sprite.SpriteEventHandler Delegate
SpriteAdjustmentRatio Structure
SpriteCollisionMethod Enumeration
SpriteController Class
SpriteDatabase Class
SpriteEventArgs Class
SpriteInfo Class
SpriteKeyEventHandler Delegate
SpritePauseType Enumeration
SpritePayload Class

# 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

https://git.solidcharity.com/timy/SpriteLibrary

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. You want to read up on SetName(String) for defining named sprites (Sprite Templates), SpriteDatabase for creating a database of sprites which are accessed on demand (this is just another way of creating Named Sprites, except you can store them in a database instead of making them programatically), and DuplicateSprite(String) for how to duplicate a sprite from a sprite template.
| 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 form, and try to avoid making and destroying new forms with SpriteController/pictureboxes in them. It is hard to destroy them completely. It is fairly simple to have multiple pictureboxes on one form. You can link SpriteControllers, which allows sprite templates (Named Sprites) to be shared between controllers. You can also use a SpriteDatabase to define sprite templates which can be used across multiple PictureBoxes.
| 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 SpriteDatabase 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. You will see this mainly when you are creating a function for one of the many Sprite Events. (see: SpriteHitsPictureBox, SpriteAnimationComplete, and SpriteHitsSprite for a few examples)
| SpriteKeyEventHandler | This is a delegate for a keypress event. You do not need to use this directly. This is defined so you can use the RegisterKeyDownFunction(SpriteKeyEventHandler) and RegisterKeyUpFunction(SpriteKeyEventHandler) functions.

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