How to trim my sprites in TexturePacker and make an animation while maintaining the relative(original) position of the sprites?

64 views
Skip to first unread message

Gael Beltran

unread,
Jun 27, 2016, 9:59:56 PM6/27/16
to melonJS - A lightweight HTML5 game engine
I'm making an animation using differently sized sprites so when I crop/trim the white/alpha unused space in TexturePacker the animation frames end up being in different positions when animated. How would I go about maintaining thei relative positions/pivot points.
Could you help me setting up TexturePacker and how to automatically apply the different pivots in melon?
Shoebox is also fine

aaron.g...@gmail.com

unread,
Jun 28, 2016, 2:15:58 PM6/28/16
to melonJS - A lightweight HTML5 game engine
Short answer: I don't know.

Typically i've turned off triming to deal with this in a number of game engines.

Gael Beltran

unread,
Jun 28, 2016, 4:11:31 PM6/28/16
to melonJS - A lightweight HTML5 game engine
I wish this was possible, I can do it in Phaser easily. Guess I'll have to switch for this project.

aaron.g...@gmail.com

unread,
Jun 28, 2016, 4:26:06 PM6/28/16
to melonJS - A lightweight HTML5 game engine
Having a look at the code, sorry for not doing so earlier, busy day. Didn't want to leave you hanging either. https://github.com/melonjs/melonJS/blob/master/src/video/canvas/texture.js#L206 saves the anchor point data (if any). Then it is set here on animation sheet as it goes through the frames: https://github.com/melonjs/melonJS/blob/master/src/renderable/animationsheet.js#L274

I haven't tried it, but have you seen any evidence of this working/not working with the anchorPoint set in the json file?

Gael Beltran

unread,
Jun 28, 2016, 5:24:40 PM6/28/16
to melonJS - A lightweight HTML5 game engine
I checked my exported json file using cropping and the anchorPoint data is there, but my animation is not using it, I'm not sure about how to use that data to set per-frame pivots/anchor points

Gael Beltran

unread,
Jun 28, 2016, 5:26:00 PM6/28/16
to melonJS - A lightweight HTML5 game engine
I use the crop, keep position setting from TexturePacker

aaron.g...@gmail.com

unread,
Jun 28, 2016, 6:26:22 PM6/28/16
to melonJS - A lightweight HTML5 game engine
Trying out our texturepacker example here: http://melonjs.github.io/melonJS/examples/texturepacker/. I removed the movement, and the animation seems fairly in place, using the pivot point stored in the json. Opening the TPS file in the repo, it has Trim mode set to Trim. When setting it to "Crop, keep position", the animation seems off.
Reply all
Reply to author
Forward
0 new messages