cocos2dx 3.1从零学习(六)——CocosStudio(VS2013project导入及环境设置)

本文介绍如何在Cocos2d-x项目中配置必要的库文件,包括libCocosStudio、libExtensions和libGUI,并解决常见的编译错误。文中还提供了使用CocosStudio导出项目的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导入libCocosStudio、libExtensions、libGUI

新建的project例如以下图:


加入现有项目

右键解决方式。例如以下操作:


分别加入下面三个项目:

(project路径)\cocos2d\cocos\ui\proj.win32\libGUI.vcxproj

(project路径)\cocos2d\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj

(project路径)\cocos2d\extensions\proj.win32\libExtensions.vcxproj

完毕后如图:



加入引用:





加入 附加包括文件夹。防止引入不了头文件:


须要有:

$(EngineRoot)cocos\editor-support
$(EngineRoot)cocos
$(EngineRoot)cocos\audio\include
$(EngineRoot)external
$(EngineRoot)external\chipmunk\include\chipmunk
$(EngineRoot)extensions
$(EngineRoot)
..\Classes


编译代码!

编译错误及解决方式:

1. 编辑器未更新

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".
在新加入的项目 右键更新VC++编译器。注意报这样的错的项目名称右边会有(VS2010***)的提示,就更新吧!


使用cocosstudio导出的project。

#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
using namespace cocos2d;
using namespace cocostudio;
using namespace ui;


新手通过json文件读取控件的时候,注意它们的父子关系。不然会崩溃。

    //载入CocosStudio导出的资源
    auto uiLayer = GUIReader::getInstance()->widgetFromJsonFile("StartUI/StartUI.ExportJson");
    this->addChild(uiLayer);

    auto bg = uiLayer->getChildByName("bg");
    auto button =(Button *) bg->getChildByName("button");
    button->runAction(MoveBy::create(1, Point(-111, 0)));
    button->addTouchEventListener(this, toucheventselector(CocosStudio::onButton) );

编译错误及解决方式:

using namespace ui; 报错的话。在前面加上using namespace cocos2d ;就能够了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值