phaser3-nineslice
phaser3-nineslice copied to clipboard
Atlas with rotated assets not supported
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:
With rotation:
Atlas image and json files with and without rotation: rotation-issue.zip
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.