phaser3-nineslice icon indicating copy to clipboard operation
phaser3-nineslice copied to clipboard

Atlas with rotated assets not supported

Open DannyT opened this issue 6 years ago • 1 comments

I added a seemingly unrelated asset to my TexturePacker atlas and my 9slice object seemed to corrupt. After a bit of noodling I realised that the additional asset had caused the TP algorithm to rotate my 9slice box asset. Unchecking allow rotation in TexturePacker fixed it but could be worth looking at for long-term support.

No rotation: no-rotation

With rotation: rotation

Atlas image and json files with and without rotation: rotation-issue.zip

DannyT avatar Jul 07 '18 21:07 DannyT

Looking at the provided example (thanks!) rotation seems to be uniformly 90 degrees clockwise.

RenderTexture supports rotation so it should be possible to rewrite the slice dimension + offset configs so that everything gets remapped and then apply a -PI/2 rotation when drawing. The mapping will look like this:

-------------           -------------
| 1 | 2 | 3 |           | 7 | 4 | 1 |
-------------           -------------
| 4 | 5 | 6 |   ---->   | 8 | 5 | 2 |
-------------           -------------
| 7 | 8 | 9 |           | 9 | 6 | 3 |
-------------           -------------

A work around, if your packer doesn't have the "disable rotation" option mentioned in report, would be to use square images.

jdotrjs avatar Jul 22 '18 19:07 jdotrjs