5/29/2023 0 Comments Texturepacker custom propertyWith a sprite sheet loaded with JSON, however, the frame is decided by the image name. You may be used to targeting a frame in a sprite sheet with a number. To load a sprite sheet with JSON we can use the atlas statement and pass in a key, the path to the sprite sheet and the path to the JSON file ("ninja", "images/ninja.png", "images/ninja.json") Setting Up the Animations Images can be of different shapes and sizes. Using JSON Animations takes away the need for that. This works well when all the images are the same size or can be spaced evenly. ![]() Normally to load a sprite sheet we use something like the code below. The JSON file contains information where each sprite sheet individual image starts and ends. This will produce two files ninja.png(the sprite sheet) and ninja.json (the information). Press the publish button at the top of the program to be able to export your sprite sheet. As long as the frame names (see below) remain the same you shouldn’t have any problems. You might want to consider using one sprite sheet for development just to get your code organized and then going ahead and creating a more efficient sprite sheet later. Whatever settings you choose should not affect the code that we are going to use to bring in the animations below. ![]() ![]() However, it may not be the most efficient way for your game. They are set up so I can see the Sprite sheet with all the sprites in order. These are the settings I typically use for my JSON Animations.
0 Comments
Leave a Reply. |