(Using Cocos2D-JS 3.2)
I wanted to test my game on Win32, and noticed animations (flipbook/spritesheet animations) are not working at all. Other actions run fine (moveTo, etc.), but cc.Animation actions seem to do nothing (note, in HTML5, everything works completely fine). So I dug a little further:
I’m creating an AnimationFrame on the Javascript side like this:
//some setup
for (var i = 0; i < frames.length; ++i)
{
var frame = frames[i];
var spriteFrame = new cc.SpriteFrame(imageSource, cc.rect(frame.x, frame.y, frame.w, frame.h));
var animFrame = new cc.AnimationFrame(spriteFrame, frame.delay);
animationFrames.push(animFrame);
}
The frames array is just filled with a bunch of {x: …, y:…, w:…, h:…, delay:…} objects that together describe an animation.
I’ve debugged both the C++ and JS side thorougly, but I’ve reached a bitter end. It seems the spriteFrame in the loop is created just fine. Debugging the C++ code, I can see that it properly sets up its arguments (e.g. (24,24) for width and (72,72) for coordinate, when the frame object was {x: 72, y:72, w: 24, h: 24}).
However, upon debugging the C++ code for AnimationFrame (js_cocos2dx_animationframe_constructor), it seems that all it does is create an empty AnimationFrame object (via its default constructor), but then just doesn’t fill it properly with data. All its attributes are their default values (e.g. the _spriteFrame is nullptr).
So all my Javascript side receives is a bunch of AnimationFrames that are invalid. So when I use them to create an animation, it obviously doesn’t work.
Is there anything I can do about this?