How to use cocostudio skeletal animation in cocos2dx-js

  • Eydamson
    Likes 0

    Problem Description

    Hi! smile
    Can you show me an example on how to use the skeletal animation made with cocostudio..
    So far I already made the animation, and when I export it it has only the .json file,
    but when i added it in a scene it is not animating.. 
    I have a daragon.csd that hast the animation
    then a dragonLayer.csd that has a background and the animated sprite(dragon.csd) inside it..

    is it seems like it is not automatically animating..

    how can I access this animation and play it?..
    can you guys show me an example? I have search the net but their examples are already deprecated.. thanks!

    and btw when i said skeleton/skeletal, what i mean is bone.. i dont know if it is different with armature.. cuz when i drag the armature in to the scene it just a single sprite, but mine is separate images animated with bones.. and when i export it cocostudio it doesnt have a plist, its just one big json file...

  • Sonar Systems admin
    Likes 0

    Have you checked the samples out

  • Eydamson
    Likes 0

    yes sir…,
    But their examples are deprecated..

    But I already found the solution..
    I just get the child with the animation by name, and get its action then  play it..
    Thanks anyway.. :)


  • Sonar Systems admin
    Likes 0

    Great :D

     

    Do you wanna post the code as a solution so the community can benefit form your knowledge.

  • Eydamson
    Likes 0

    ooopps! smiley

    heres the code

    var layer = ccs.load(“json file”);
    scene.addChild(layer.node);
    var nodeWithTheAnimations = layer.node.getChildByName("node name");
    nodeWithTheAnimations.retain();// for native platform
    var action = nodeWithTheAnimations.actionManager.getActionByTag(tagNo,nodeWithTheAnimations);// tag number is the tag of the node in the layer
    action.retain();// for native platform
    action.setTimeSpeed(0.2);// this can be removed; the default speed is 1, speed is the a floating point between 0-1 (this is the animation speed)
    action.gotoFrameAndPlay(0,130,true);// 0 and 130 are the frames to be played, the boolean im not sure what it is for blush
    
    
    im not sure if it will work on you guys…
    but it works for me, hope it helps smiley
    
    

    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Great :D


Login to reply