Update UsingSprites

Tim Young 2017-10-04 03:14:34 +02:00
parent 0f6c7dcfb9
commit 64c1246a45

@ -26,6 +26,8 @@ A SpriteDatabase is another way to define named sprites. If your program only h
The database allows you to build a file that defines all your sprites. If you instantiate your SpriteController with the Database, or you add it using SetSpriteDatabase, the SpriteController will reference the database when you asked for a named sprite. The nice thing about this, is that it spreads out the creation of sprites. In the AdventureDemo example, it took four or five seconds for the game to start while the SpriteController was creating the initial sprites. If a Database was used, the sprites would only be created when first referenced, which means that the load-time is virtually un-noticeable. The database allows you to build a file that defines all your sprites. If you instantiate your SpriteController with the Database, or you add it using SetSpriteDatabase, the SpriteController will reference the database when you asked for a named sprite. The nice thing about this, is that it spreads out the creation of sprites. In the AdventureDemo example, it took four or five seconds for the game to start while the SpriteController was creating the initial sprites. If a Database was used, the sprites would only be created when first referenced, which means that the load-time is virtually un-noticeable.
![The SpriteDatabase window for adding Sprites](images/SpriteDatabase.png)
The SpriteDatabase has the additional benefit of letting you define your sprites through a GUI. The OpenEditWindow function will allow you to browse through the images which you have already added as resources to your project. You can highlight an item to turn into a sprite, specify the number of frames, and even preview the sprite. The SpriteDatabase has the additional benefit of letting you define your sprites through a GUI. The OpenEditWindow function will allow you to browse through the images which you have already added as resources to your project. You can highlight an item to turn into a sprite, specify the number of frames, and even preview the sprite.
Resources are read-only, so you use this function by instantiating the database by giving it a filename. Then you use the OpenEditWindow function of the database. When you are done defining your sprites, you can add the file as a resource to your program, and then instantiate the database using the resource name instead of the filename. Resources are read-only, so you use this function by instantiating the database by giving it a filename. Then you use the OpenEditWindow function of the database. When you are done defining your sprites, you can add the file as a resource to your program, and then instantiate the database using the resource name instead of the filename.