Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Anchor/Pivot points

$
0
0

@dryhfth wrote:

Hello!
I' m writing a small game demo, using Monogame.Extended libraries.
I wonder, if pivot data is exported from jsonMap, I was looking for export entries in source code, but couldn't find. :hushed:
For example: I have TextureAtlas & Map created via TexturePacker/SpriteSheetPacker, something like this:

{frames: [
{
    "filename": "Frame1.png",
    "frame": {"x":823,"y":612,"w":76,"h":97},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x:":3,"y":0,"w":76,"h":97},
    "sourceSize": {"w":80,"h":97},
    "pivot": {"x":0.523697,"y":0.345168}
},
{
    "filename": "Frame2.png",
    "frame": {"x":823,"y":711,"w":76,"h":96},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x:":3,"y":1,"w":76,"h":96},
    "sourceSize": {"w":80,"h":97},
    "pivot": {"x":0.603516,"y":0.411546}
}

//C#
tAtlas = Content.Load<TextureAtlas>(@"textureMap");
SpriteSheetAnimationFactory spaFactory = new SpriteSheetAnimationFactory(tAtlas);
spaFactory.Add("Idle", new SpriteSheetAnimationData(array(0-10), 0.2f));
spaFactory.Add("Attack1", new SpriteSheetAnimationData(array(11-20), 0.04f, false));
spaFactory.Add("Attack2", new SpriteSheetAnimationData(array(21-30), 0.04f, false));
animSprite= new AnimatedSprite(spaFactory, "Idle");

But actually it doesn't work (anchoring) :disappointed_relieved:. Seems like all data is imported except pivot data, which is essential to me, because I'm using SpriteSheet with different-sized frames.
Am I missing something or do I need to create separate wrapper or processor which will read this data??

To illustrate, what I mean: SpriteOrigin
Yellow border is frame size & red square is origin.
The best way it works, when I place origin in center-bottom position, not perfectly though. :neutral_face:

Will appreciate any advice :pensive:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles