Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Flash -> Texture Packer -> Phaser


mcolman
 Share

Recommended Posts

Hi guys,

 

I'm using Flash to create graphics, exporting to a swf file, importing into Texture Packer and then exporting to a JSONArray.

 

If you set your Flash stage size the same as your Phaser stage size, then the workflow is potentially very efficient.

 

I should be able to add all my different sprites to the stage and they will appear in exactly the right spot right? 

 

Well this does work, but when I try to change the anchor point I'm running into problems.

 

If I use 'Trim' mode in TP, the anchor point is then based on the Flash stage size, rather than the bounds of the sprite, so this is no good.

If I use 'Crop, keep position' mode in TP, the anchor point is now correctly based on the sprite bounds, but the spriteSourceSize values are no where to be seen in Phaser. I can still see the correct spriteSourceSize object in the json file, but it seems because "trimmed" is now set to "false", that these values don't make it into Phaser at all.

 

So yes, I can fix the problem by changing all "trimmed" values to true, but this is not ideal.

 

Has anyone else run into the same problem? Any ideas for how to get around this? Am I doing something stupid?

 

Thanks!

 

Matt.

Link to comment
Share on other sites

TLDR; (above)

 

I'd like to change this topic to "'Crop, keep position' Texture Packer setting doesn't work in Phaser".

 

"Crop, keep position" does keep the position in the json file, but it sets "trimmed" to false.

 

In Phaser when "trimmed" is set to false it ignores all the spriteSourceSize data. https://github.com/photonstorm/phaser/blob/dev/src/animation/AnimationParser.js#L129

 

So is this a Phaser bug or a Texture Packer bug...or my bug?

 

Should Phaser always call setTrim() regardless of the 'trimmed' flag? I don't see a problem with this. When you use the "crop, flush position" setting it just sets x and y to 0.

or should Texture Packer set trimmed to true when using 'crop, keep position'?

 

Cheers,

Link to comment
Share on other sites

I abandoned that method a while ago because it wasn't up to scratch, but now, like TP, it almost works :/

So choosing the 'trim' option sets 'trimmed' to true AND the spriteSourceSize is correct for each sprite...but, it seems Flash is only expecting to export a spritesheet, not an atlas. So the names just come out as "all instance 10000", "all instance 10001" etc, instead of reading the frame labels.

 

Anyway, I'll find a workaround, I think it's just not what I'm used to. Will send an update once I find a good workflow. 

 

Cheers,

Link to comment
Share on other sites

The idea behind the "trimmed" value is the following: Trimmed=true means that the sprite should be treated as if it still has it's original size. This is why it is set to false in the trimmed case.

 

I've created a fix for Phaser - setting the "trimmed" value to true in the CropKeepPos cases. It'll be contained in the next TexturePacker update. (That means any release >3.9.4).

You'll have to use the "Phaser (JSONArray)" or "Phaser (JSONHash)" format. I can't change the generic JSON data format for that - simply because I have no idea who might be hit by the change. Sorry.

 

If you need this build urgently contact me at _support at codeandweb.com_ - I am happy to send you a build with the fix until the next release.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...