Together with Artem Anisin we have developed a new feature for Defold.
Texture sizes can be greatly reduced by trimming transparent pixels around the actual sprite image.
Trimmed Images in Atlas
This feature introduces new fields for images in the atlas outline pane. Namely Source Position X
, Source Position Y
, Source Width
, Source Height
.
Source Position X
and Source Position Y
indicate the position offset of the trimmed image inside the original image from the top left corner. Source Width
and Source Height
indicate the original image size and they are needed to correctly center the trimmed image inside the animation frame.
TexturePacker Support
Now you can use TexturePacker to generate atlas files with trimmed images.
The exporter supports storing atlas settings and animations settings such as margin, padding, FPS, playback and so on.
It has to be installed in TexturePacker as a custom exporter (create a dir, select it as custom exporters dir in TexturePacker settings, copy defold
dir from the repo into that dir).
TexturePacker not only can trim images but also can detect identical sprites saving up disk space even further.
Spritesheet Split Editor Script
Use this editor script to split up the spritesheet from TexturePacker into individual files for Defold.
Pull Request
The feature is not yet available in Defold but there is a pull request on GitHub, give it a like!
There is no guarantee itâs going to be accepted and merged but I hope it will.
Preview
Erica atlas with no trimming is 4096x2048
Erica atlas with trimming is 2048x2048
TexturePacker Exporter
Spritesheet Split Editor Script
Comparison between trimmed sprite and full sprite in the collection
The green area is the sprite polygon shape shown using a custom shader.
Comparison between trimmed sprite and full sprite at runtime
The green area is the sprite polygon shape shown using a custom shader.