cocos2dx运行从cocos studio导出的Json到动画

cocos2dx running exported Json from cocos studio into an animation

本文关键字:Json 动画 运行 cocos studio cocos2dx      更新时间:2023-10-16

我正在尝试从CocosStudio读取/加载导出的JSON和资源(这是一个生成动画的工具)但是,当我试图加载或读取接缝,这不是任何类或函数,以加载此文件。我做了一个网络调查,我发现的都是废弃的代码或外部库等。认为:

auto animation animation =             extension::ccSkeletonAnimation::createWithFile("FILE.JSON","FILE.ATLAS");
animation->setPosition((x+y));
animation->setAnimation("a",true);
this->addChild(animation,0);

上面的代码使用了一个类似于"cocosStudio"的外部工具,叫做"Spin"

有什么可以提供一些指导关于这个…?或者适当的类来设置一个JSON文件的动画?cocos2dx版本为3.1提前感谢!最好的问候!

我使用这段代码将动画从cocostudio导入到visual studio 12

    cocostudio::Armature* armature;  
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("DemoPlayer0.png","DemoPlayer0.plist","DemoPlayer.ExportJson");
        armature = Armature::create("DemoPlayer");
        armature->setPosition(ccp(visibleSize.width * 0.8,visibleSize.height * 0.5));
        armature->getAnimation()->playByIndex(0);
        armature->setScale(0.25);
        this->addChild(armature);

或者您可以在cocostudio的帮助部分查看此代码。

//async loading export file
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Cowboy0.png","Cowboy0.plist","Cowboy.ExportJson");
//Creat armature by name
CCArmature *armature = CCArmature::create("Cowboy");
//play animation by animation index
armature->getAnimation()->playByIndex(0);
//Change Permissions
armature->setScale(0.5f);
//Set the armature position
armature->setPosition(200,300);
//add to the current scene
this->addChild(armature,2)