previousAnimationIndex = currentAnimationIndex.// If not, then the next animation should be the left-side sprite.// If the previous animation was the left-side sprite, then the next animation should be the right-side sprite.// If Alex is in the middle sprite of the animation.// Check if the timer has exceeded the threshold. To give a quick example, use the following code: This tells the game to only draw the part of the texture within the sourceRectangle. In spriteBatch.Draw() you can set a sourceRectangle. As you can see from the below image (and from previous tutorials) this texture contains his entire up, right, down, and left movement animation. This is called a sprite sheet – or alternatively a texture atlas, character set, chipset, or other terms.įor this example we’re returning to Alex, our good friend from RPGMaker 2000. To greatly simplify the number of graphical assets you need to load and keep track of, it’s easier to bundle related sprites into a single image file. The following C# code will show you how to use sprite sheets to display graphics in a MonoGame project.Ī 2D game requires a lot of sprites for characters and levels. In this tutorial we assume you have completed the following tutorial and added/loaded the Texture2D " charaset" to your project: Learn about using sprite sheets to consolidate your graphics and to enable animation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |