Difference between revisions of "Create Sprite Sheet"
From Future Skill
Line 24: | Line 24: | ||
</div> | </div> | ||
Which will create the image <code>res_25_skilly_walking_v1.png</code> and the atlas <code>res_25_skilly_walking_v1.json</code>. | Which will create the image <code>res_25_skilly_walking_v1.png</code> and the atlas <code>res_25_skilly_walking_v1.json</code>. | ||
+ | |||
+ | The image atlas created by spritesheet.js will not contain any animations. When uploading the sheet in the freecode creator you also have to uplad the image atlas. when doing this it is possible to use a "Generate Animation" button that will create the "default" animation iterating over all the images in the sheet. For this reason it is recommended to have one specific animation in each sheet. |
Revision as of 16:08, 13 April 2021
A sprite sheet is an image containing many individual images. The sheet must be complemented with an image atlas object that contains the information of where in the sprite sheet each individual image can be found and what animations the images are used for.
Sprite sheets compatible with the Futureskill platform require that each individual image is exactly the same size in each sprite sheet. If they are not the same size the images will stretch to accomodate the size defined for the sprite_sheet element in the implementation code.
The Sprite sheet atlas must be a JSON compatible with the PIXI.js framework. A free tool that can be used to generate sprite sheets from individual sprite images is https://github.com/krzysztof-o/spritesheet.js.
Using spritesheet.js
Each sprite image must be in the same folder and have the same name, except for a number that should indicate which animation fram that image is. If we have a number of images of skilly walking that we want to turn into a walking animation then they could be named skilly_walking_00001.png
where the number in the name increases for each fram of animation.
If we want to turn the skilly_walking_*.png images into a sprite sheet we can run the command:
spritesheet-js -f pixie.js -n skilly_walking_v1 skilly_walking_*.png
Which will create the files skilly_walking_v1.png
and skilly_walking_v1.json
, where the png is the sprite sheet image and the json is the image atlas containing information about where each sprite is in the sheet.
The command above will not remove any white space or compress the image in any way. If we want to remove unnecessary whitespace and compress the image to 25% we can instead run the command:
spritesheet-js -f pixie.js --scale 25% --trim -n res_25_skilly_walking_v1 skilly_walking_*.png
Which will create the image res_25_skilly_walking_v1.png
and the atlas res_25_skilly_walking_v1.json
.
The image atlas created by spritesheet.js will not contain any animations. When uploading the sheet in the freecode creator you also have to uplad the image atlas. when doing this it is possible to use a "Generate Animation" button that will create the "default" animation iterating over all the images in the sheet. For this reason it is recommended to have one specific animation in each sheet.