cocos2d-x 3.2 lua 怎么导入cocostudio动画

cocos2d-x 3.2 lua 怎么导入cocostudio动画,第1张

Cocostudio目前的功能包括UI编辑器动画编辑器、场景编辑器和数据编辑器。数据编辑器没有涉及到,就不说了。剩下三者中主要讲下导入UI编辑器的资源。

UI编辑器导出的文件包括一个ExportJson文件,一个plist文件和一个png文件。Cocostudio中文官网中说的是TouchGroup,英文官网中是UILayer,可是都已经不存在了。UILayer变成了Layer,现在也可以不创建Layer,直接加到场景上面。所以代码可以这样:

Node pNode = GUIReader::getInstance()->widgetFromJsonFile("testExportJson");

this->addChild(pNode);

下面就可以用getChildByTag来获取组件了。不过getChildByTag貌似只能按照树的结构一层层照下来,显得很麻烦,而且不能按照名字来取。所以,现在可以用ui中的Helper直接从树中获取组件,用name或者tag。但seekWidgetByTag和seekWidgetByName的第一个参数是Widget类型,需要将pNode转成Widget类型。(从ExportJson文件可以看出来,pNode本来就是一个Widget类型的树)

Button button = (Button)(ui::Helper::seekWidgetByName(pNode, "button"));

顺便附上绑定事件监听的代码,使看到的人免去寻找之苦。

button->addTouchEventListener(CC_CALLBACK_2(MainScene::touchEvent, this));

touchEvent是自己写的方法。这个方法大致是如下用法,注意pSender和type的使用。

void SingleMenuScene::selectEvent(Ref pSender, Widget::TouchEventType type)

{

switch(type)

{

case Widget::TouchEventType::ENDED:

GameSetting::Map map = GameSetting::Map::DEFAULT;

if(pSender == defaultBtn)

{

map = GameSetting::Map::DEFAULT;

}

else if(pSender == snowBtn)

{

map = GameSetting::Map::SNOW;

}

Scene game = BattleScene::createScene(map);

TransitionScene transition = TransitionFade::create(05, game);

Director::getInstance()->replaceScene(transition);

}

}

导入动画编辑器的动画的代码如下:

CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Animation0png","Animation0plist","AnimationExportJson");

CCArmature armature = CCArmature::create("Animation");

armature->getAnimation()->playByIndex(0);

armature->setScale(05f);

armature->setPosition(ccp(visibleSizewidth 05, visibleSizeheight 05));

this->addChild(armature);

导入场景编辑器的场景的代码如下:

Node pNode = SceneReader::getInstance()->createNodeWithSceneFile("sceneExportJson");

this->addChild(pNode);

这个读出的Node貌似不能转成Widget,因为它不仅包括UI组件还有动画等资源。获取组件和绑定事件监听可以这样写:

ComRender render = (ComRender)(pNode->getChildByTag(10010)->getComponent("GUIComponent"));

Widget widget = (Widget)(render->getNode());

widget->addTouchEventListener(CC_CALLBACK_2(MainScene::touchEvent, this));

在运用Entity Framework调用存储过程的时候,遇到"调用EF的存储过程报"调用EF的存储过程报“存储区数据提供程序返回的数据读取器所具有的列数对于所请求的查询不够”问题"的问题,存储过程是用EF模型的函数导入(设置映射的存储过程)。检查过存储过程,在Sql Management Studio运用是正常的。

你可以先去绘学霸网站找“动画制作技术”板块的免费视频教程-点击进入完整入门到精通视频教程列表: >

以上就是关于cocos2d-x 3.2 lua 怎么导入cocostudio动画全部的内容,包括:cocos2d-x 3.2 lua 怎么导入cocostudio动画、各位大仙,xcode编译,cocostudio.h file not found,为什么、目前做2D骨骼动画 Spine和Coco studio哪个软件好等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9672233.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存