craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 324 forks source link

TexturePacker format lacking rotation/trimming functionality. #634

Open anaanook opened 5 years ago

anaanook commented 5 years ago

Feel free to close this if I am mistaken, but as far as I can tell the TexturePacker json is lacking a few critical features, mainly sprite trimming/rotation flags.

 {
    "filename": "tiles1.26.png",
    "frame": {"x":160,"y":256,"w":18,"h":32},
    "rotated": true,
    "trimmed": true,
    "spriteSourceSize": {"x":7,"y":0,"w":18,"h":32},
    "sourceSize": {"w":32,"h":32}
},

When imported, TextureRegion2D doesn't seem to track the offset position(x and y of spriteSourceSize) and whether or not the sprite was rotated to fit, as well as correctly drawing them in offset/re-rotated space when using the spritebatch.draw extensions.

Anyways, big fan of the implementation, this one tiny thing is holding me back.

craftworkgames commented 5 years ago

Yep, it's true. There's currently some limitations on what features you can use in Texture Packer.

The workaround is obviously to not use those features when you're packing your sprites.

A better solution would be to implement those changes in MonoGame.Extended. I'll accept pull requests but please make sure there's a demo included to show that it can load these kinds of texture packer files.

Let's leave this issue open until it's implemented.