SpriteLibrary

# SpriteDatabase Methods

The SpriteDatabase type exposes the following members.

Methods

| Name | Description
--- | --- | ---
| CloneByXMLSerializing T | This is an inefficient, but simple function to clone a class. It works by serializing an item to a string, and then deserializing it into a class. The end result is that any value which is publically visible is duplicated, but it is a completely separate class from the original.
| Equals | (Inherited from Object.)
| Finalize | (Inherited from Object.)
| GetHashCode | (Inherited from Object.)

GetImageFromName

This function returns an image from the Properties.Resources. If we tell it to UseSmartImages, then it caches the image in memory. This makes it a little faster to return. If you have a lot of sprites to load, using this system can speed up things a fair bit. But, try to remember not to change the image that this returns unless you duplicate it first. Otherwise you will end up changing the image for all the other times you reference it. This is usualy a bad thing.

| GetImageNames | Return a list of the image names in the Properties.Resources
| GetType | (Inherited from Object.)
| LoadObjectFromXmlFile T | Load in an XML serialized item from the specified ResourceManager. You will usually make one of these by creating an object and using WriteToXmlFile T (String, T) SpriteDatabase.WriteToXmlFile to save it to a file on your desktop. Then you can drag and drop that file into your project and then use this LoadObjectFromXmlFile function.
| MemberwiseClone | (Inherited from Object.)
| OpenEditWindow | Open a Sprite Edit Window. This window does not let you draw a sprite. What it does is to help you define your sprites and makes the process of using Sprites in your program a lot easier.
| ReadFromXmlFile T | Reads an object instance from an XML file. Object type must have a parameterless constructor.
| ReadFromXmlString T | This is a generic function which the SpriteDatabase uses. It does XML Deserialization of most anything, and generates an XML String. XML Serialization will take any public value of a public class and make an XML entry for it. It is a very convienent way to save and retrieve data. You can "Serialize" the value with the WriteToXMLString function.

Save

Tell the database to save the sprite definitions. Use this while you are creating your game. When you are done, you will usually want to take your sprite definition file and add it to the resources of your game. The resources cannot be saved to, so you cannot continue to add new sprites once you are loading and saving them from a resources file. But, the resources file is included with the program when you build it.

| SetIcon | Change the Icon for the SpriteEntryForm
| SetSnapGridSize | The SnapGrid is the block-size that your sprite will be. For example, I will often have sprites with a snapgrid of 50,50. This means that the sprite can be 50x50, 100x50, or anything with a step-size specified in the snap-grid. It takes a "Size" specified by System.Drawing.Size.
| SpriteFromName | Generate a new, named sprite from a sprite template stored in the database. Most of the time you do not want to use this yourself. SpriteControllers that are defined with a database will automatically look up sprite templates that they do not have sprites for. This function is just a wrapper for SmartDuplicateSprite.
| SpriteNames | Return a list of the SpriteNames that this Database knows how to create.
| ToString | (Inherited from Object.)
| WriteToXmlFile T | Writes the given object instance to an XML file. Only Public properties and variables will be written to the file. These can be any type though, even other classes. If there are public properties/variables that you do not want written to the file, decorate them with the [XmlIgnore] attribute. Object type must have a parameterless constructor.
| WriteToXMLString T | This is a generic function which the SpriteDatabase uses. It does XML Serialization of most anything, and generates an XML String. XML Serialization will take any public value of a public class and make an XML entry for it. It is a very convienent way to save data. You can "Deserialize" the value with the ReadFromXMLString function.

Top
See Also

#### Reference

SpriteDatabase Class
SpriteLibrary Namespace