I am learning Cocos2d JS, but I can find very few tutorials and I find the documentation very vague. I can put a simple image on a layer like this:

var sprite = new cc.Sprite(res.my_image_png);
sprite.setAnchorPoint(0.5, 0.5);
sprite.setPosition(cc.winSize.width / 2, cc.winSize.height / 2);

I can also move it like this:

var actionTo = cc.moveTo(2.5, cc.p(100, 100).easing(cc.easeInOut(1));

    new cc.Sequence(
        new cc.CallFunc(
            function() {
                cc.log("Animation complete");

How could I improve this code to also show some sprite-based animation? I would like to exchange the sprite image every 0.25 seconds. What is the designed way to do that in Cocos2d JS?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.