koreezgames / phaser3-ninepatch-plugin

Nine Patch plugin for Phaser3!
MIT License
71 stars 3 forks source link

Support anchor/pivot point in atlas #31

Open DannyT opened 4 years ago

DannyT commented 4 years ago

Atlas/Sprite sheet creation tools like TexturePacker offer the ability to set anchor/pivot points on images. NinePatch currently doesn't take these into account.

In this screenshot I have loaded an image from my atlas, once using this.add.image and once using this.add.ninePatch, both defining the same x and y position:

image

In TexturePacker, the pivot point is set to 0, 0 (top left) which the default phaser image add is respecting but not in NinePatch.

This is the relevant json from the atlas:

{
    "filename": "controls/beige-panel.png",
    "rotated": false,
    "trimmed": false,
    "sourceSize": {
        "w": 100,
        "h": 100
    },
    "spriteSourceSize": {
        "x": 0,
        "y": 0,
        "w": 100,
        "h": 100
    },
    "frame": {
        "x": 4,
        "y": 1,
        "w": 100,
        "h": 100
    },
    "anchor": {
        "x": 0,
        "y": 0
    }
}

Would be great to have support for this if at all possible 🙏