Click or drag to resize

SpriteDatabase Class

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.
Inheritance Hierarchy
SystemObject
  SpriteLibrarySpriteDatabase

Namespace:  SpriteLibrary
Assembly:  SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
public class SpriteDatabase

The SpriteDatabase type exposes the following members.

Constructors
  NameDescription
Public methodSpriteDatabase
The sprite database instantiation function. The filename can either be a file on the computer or it can be the string name of a resource (the filename without the extension. If your file is accessed by Properties.Resources.MySprites, the "filename" would be "MySprites")
Top
Methods
  NameDescription
Public methodStatic memberCloneByXMLSerializingT
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.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetImageFromName
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.
Public methodGetImageNames
Return a list of the image names in the Properties.Resources
Public methodGetType (Inherited from Object.)
Public methodStatic memberLoadObjectFromXmlFileT
Load in an XML serialized item from the specified ResourceManager. You will usually make one of these by creating an object and using WriteToXmlFileT(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.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleOpenEditWindow
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.
Public methodStatic memberReadFromXmlFileT
Reads an object instance from an XML file.

Object type must have a parameterless constructor.

Public methodStatic memberReadFromXmlStringT
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.
Public methodSave
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.
Public methodSetIcon
Change the Icon for the SpriteEntryForm
Public methodSetSnapGridSize
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.
Public methodSpriteFromName
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.
Public methodSpriteNames
Return a list of the SpriteNames that this Database knows how to create.
Public methodToString (Inherited from Object.)
Public methodStatic memberWriteToXmlFileT
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.
Public methodStatic memberWriteToXMLStringT
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
Fields
  NameDescription
Public fieldSpriteInfoList
This is the list of SpriteInfo records that the database knows about. You can create your own list, modify this list, or whatever. The database has some reasonable functions for loading and saving a sprite database.
Top
See Also