【cocos2dx 3.10】简述 cocos studio 的使用

1.创建场景

略过,自己打开cocos studio自己随便弄就会了。


2.发布项目

菜单->项目->发布与打包-> 发布->发布资源->确定


点“确定”按钮后,资源会发布到“/Resource/res”,这是默认路径,可以自己修改


3.给按钮添加事件

如果你在cocos studio添加了一个按钮,是不是要指定一个点击回调函数。代码如下:

#include "cocos2d.h"
#include "ui/CocosGUI.h"

USING_NS_CC;
using namespace cocos2d::ui;

ui::Button* _testButton = nullptr;

//init函数
	//按钮
	_testButton = static_cast(rootNode->getChildByName("start"));
	_testButton->addClickEventListener(CC_CALLBACK_1(HelloWorld::testClick, this));


添加输入框和获取内容,代码如下:

ui::TextField* _testTextField = nullptr;

//输入框
	_testTextField = static_cast(rootNode->getChildByName("TextField_1"));

  CCLOG("%s" , _testTextField->getString());



注:

1.cocos studio里面的名称就是节点名称,可以通过getChildByName获取节点

2.逻辑标签就是tag

3.注意父子关系,别到时候说获取不到节点。

你可能感兴趣的:(cocos2d)