Aseprite cocos2dx sprite sheet with frame delays

Hello,
I’ve read about this topic but never in a recent thread, so I ask in case something has changes in last cocos2dx. I have been around cocos for a while but never had time to really to really practice, so I am starting from scratch. I have one png file sprite sheet containing an idle (5 frames ) and a walk(4 frames) exported from aseprite. And Aseprite also gives you the option to export a .json file with it that looks like this:

{ “frames”: [
{
“filename”: “idleAndWalk #idle 0.aseprite”,
“frame”: { “x”: 0, “y”: 0, “w”: 31, “h”: 62 },
“rotated”: false,
“trimmed”: true,
“spriteSourceSize”: { “x”: 15, “y”: 2, “w”: 31, “h”: 62 },
“sourceSize”: { “w”: 64, “h”: 64 },
“duration”: 300
},
{
“filename”: “idleAndWalk #idle 1.aseprite”,
“frame”: { “x”: 31, “y”: 0, “w”: 31, “h”: 62 },
“rotated”: false,
“trimmed”: true,
“spriteSourceSize”: { “x”: 15, “y”: 2, “w”: 31, “h”: 62 },
“sourceSize”: { “w”: 64, “h”: 64 },
“duration”: 100
}, etc…}

So I wonder what is the best way today to load the animations in cocos2dx.
My goal here is just to lear how to load right the animation including the duration, so I don’t just want to iterate in a loop all frames with the same durations as I’ve seen in most examples.
Can you give some guidance from here?

thank you
R

I’m sorry, I don’t quite understand what you need help with? I am not sure about the tool that you mention also.

sure, let me more specific.
aseprite is a 2d animation software that output a .sprite sheet + a json file as shown in the example.
so as can see the frames key has multiple items were, for instance, the first sprite is dleAndWalk #idle 0. and has a duration of 300 ms, the sprite is dleAndWalk #idle 1 and has a duration of 100 ms…etc…

So my question is if cocos 2dx can read from a json file like this, to create a animation that automatically adds the duration to the corresponding frame.
with class Animation::create() you can set as firt argument the frames, and the second the duration right?
but this set the same duration to all frames. What I want is to assing to each frame the duration corresponding to the data I have in the json file.

Yes I think you could import the json using any standard library and then map your json structures with cocos2d objects, initialize variables with json, etc.

I use custom file formats in all of my games.

Okey thanks. I got it working using AnimationFrame which allows to add delays for each sprite.

Vector<AnimationFrame*> frames;
ValueMap info;
auto frame1 = spriteFrameCache->getSpriteFrameByName("idle_1.png");
frames.pushBack(AnimationFrame::create(frame1, 3, info));
auto frame2 = spriteFrameCache->getSpriteFrameByName("idle_2.png");
frames.pushBack(AnimationFrame::create(frame2, .5, info));
auto frame3 = spriteFrameCache->getSpriteFrameByName("idle_3.png");
frames.pushBack(AnimationFrame::create(frame3, 1, info));

auto animation = Animation::create(frames, 0.1f);
animation->setLoops(-1);

The thing that I don’t understand is the second argument in Animation::create(frames, 0.1f); I know it is a delay, but if I just added above the delays for each frame, why the constructor forces me to add a second argument again?

actually never mind, I understood now.