How to avoid Animation data be covered by cocos2dx?

626 Views Asked by At

I use cocostudio to create some animation export files , it has .ExportJson , .plist , .png .And I use following code to load it in cocos2dx 3.2:

cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_die/monkey_die.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_jump/monkey_jump.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_run/monkey_run.ExportJson");

But when I want play the monkey_run animation use :

cocostudio::Armature * armature = cocostudio::Armature::create("monkey_run");
addChild(armature);
armature->playWithIndex(0);

The animation is monkey_die! So I change the code :

cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_run/monkey_run.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_die/monkey_die.ExportJson");
cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("monkey_jump/monkey_jump.ExportJson");

I just let run in front of die . The I can play the monkey_run correctly.

I'm green hand to cocostudio. So I think it must be the export files' problem . I use some default name in cocostudio. Which of them can cause the problem?

1

There are 1 best solutions below

1
On BEST ANSWER

I got this resolved recently. It is because the same image file name. For example, in your three animations, you may have this file: monkey_head.png. Try to rename the image file into different names, like monkey_head_die.png, monkey_head_jump.png. And do the same thing for rest of images. Hope it helps.

Leo