Update quickstart

Tim Young 2017-10-04 03:07:23 +02:00
parent 6932572bb6
commit 4e78ea25e2

@ -1,9 +1,11 @@
# Quick-Start # Quick-Start
## Adding a Reference ## Adding a Reference
In your project (make a new project if you do not have one already), right-click “References” in the “Solution Explorer” and “Add Reference.” Go down to “Browse” and find the SpriteLibrary DLL. If you have built it (see above), it should be in your projects/SpriteLibrary/SpriteLibrary/Bin/Release directory. If you develop a game and use the built-in ClickOnce installer, this DLL will be automatically installed, along with your package, now that you have added it as a reference. So you should only need to do this once per project. In your project (make a new project if you do not have one already), right-click “References” in the “Solution Explorer” and “Add Reference.” Go down to “Browse” and find the SpriteLibrary DLL. If you have built it (see above), it should be in your projects/SpriteLibrary/SpriteLibrary/Bin/Release directory. If you develop a game and use the built-in ClickOnce installer, this DLL will be automatically installed, along with your package, now that you have added it as a reference. So you should only need to do this once per project.
![Adding a reference](images/AddingAReference.png)
## Using the Sprite Library ## Using the Sprite Library
You need to add a “using SpriteLibrary;” at the top of your main form, and in any code file (class, form, etc) where you reference the pieces of the Sprite Library (the Sprites, the SpriteController, etc.) You need to add a “using SpriteLibrary;” at the top of your main form, and in any code file (class, form, etc) where you reference the pieces of the Sprite Library (the Sprites, the SpriteController, etc.)
![using SpriteLibrary](images/UsingSpriteLibrary-AddReference.png)
## Initializing the Sprite Library ## Initializing the Sprite Library
In the form that you want to use for a game, you will want to create a SpriteController. You will need to define it first as a variable. Something like: In the form that you want to use for a game, you will want to create a SpriteController. You will need to define it first as a variable. Something like:
@ -28,6 +30,7 @@ Sprite JellyMonster = new Sprite(new Point(0, 100), MySpriteController,
JellyMonster.SetName(“jelly”); JellyMonster.SetName(“jelly”);
``` ```
In this example, we are making a sprite named JellyMonster by pulling the animation out of the second row of the image “Properties.Resources.monsters”. (0,0 is the first row, 0,100 is the second row.) We pass it the sprite controller, and then the “monsters” image file. We specify that the image we are pulling out is of the size 100 x 100. We use an animation speed of 200ms per frame, and we pull 4 frames out of the image. When we print the sprite, we can grow, or shrink the sprite on the PictureBox. It does not need to remain at 100x100. That is just the size of the individual frame in the sprite sheet image. In this example, we are making a sprite named JellyMonster by pulling the animation out of the second row of the image “Properties.Resources.monsters”. (0,0 is the first row, 0,100 is the second row.) We pass it the sprite controller, and then the “monsters” image file. We specify that the image we are pulling out is of the size 100 x 100. We use an animation speed of 200ms per frame, and we pull 4 frames out of the image. When we print the sprite, we can grow, or shrink the sprite on the PictureBox. It does not need to remain at 100x100. That is just the size of the individual frame in the sprite sheet image.
![The Monsters Sprite Sheet](images/Properties-Resources-Monsters.png)
The last step we do in the above code is to name the sprite. We name our master sprites, and then clone them when we want to have a bunch of them. We usually will not have the named sprites display on the screen without cloning (though you can). The main reason we do this is so that we can destroy sprites at our leisure, and make as many of them again whenever we want. When you destroy a clone, it is easy to make more from the master. But destroying the master means you need to start from scratch. It is very efficient to clone sprites, but it takes a lot more effort to generate new ones from scratch. The last step we do in the above code is to name the sprite. We name our master sprites, and then clone them when we want to have a bunch of them. We usually will not have the named sprites display on the screen without cloning (though you can). The main reason we do this is so that we can destroy sprites at our leisure, and make as many of them again whenever we want. When you destroy a clone, it is easy to make more from the master. But destroying the master means you need to start from scratch. It is very efficient to clone sprites, but it takes a lot more effort to generate new ones from scratch.
You clone a sprite by doing something like: You clone a sprite by doing something like: