Necessary
Libraries:
#include "cocostudio\CocoStudio.h"
Skeleton Files:
*.ExportJson
*.plist
*.png
Tool:
- Cocostudio (Animation Editor) you can get it on
cocos2d-x.org
- On Cocos Store: it’s name Cocos Skeletal
Animation Editor
Setup and Run
1. we will add Skeleton Files into ArmatureFilesInfo:
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(*.png, *.plist, *.ExportJson);
2. get Animation:
Armature *hero = Armature::create("Hero");
You can get name of
Skeleton by seeing in file *.ExportJson (the first properties “name”) or default
it’s named by Project Name on Cocostudio
3. Play Animation:
hero->getAnimation()->playWithIndex(animationIndex,
durationTo, loop);
-
animationIndex:
Index of animation (0 is the first animation)
-
durationTo: how many
frames between animation changes
-
loop: it have two
kinds : if it > 0 animation is loop and reverse use the value from MovementData
get from flash design panel
4. Add to Node:
This->addChild(hero)
5. enjoy winning :D
* entire code:
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Hero/Hero0.png", "Hero/Hero0.plist", "Hero/Hero.ExportJson");
Armature *hero= Armature::create("Hero");
//hero->setScale(0.1f);
hero->getAnimation()->playWithIndex(2, -1, 1);
hero->setPosition(200, 200);
this->addChild(hero);
in Resources folder I have folder Hero which contains Hero.ExportJson , Hero0.plist , Hero0.png
0 Comment:
Post a Comment