需要包含文件及名字空间:?123 <ol><li>#include "cocostudio/CocoStudio.h"</li><li></li><li>#include "ui/CocosGUI.h"</li><li></li><li>using namespace cocos2d::ui;</li><li></li><li>using namespace cocostudio;注:工程需要附加包含文件目录:$(EngineRoot)cocos\editor-supportcocostudio目录</li></ol>获取UI控件:m_achievementLayer = dynamic_cast<layout*>(GUIReader::getInstance()->widgetFromJsonFile("achievements/achievements.json"));addChild(m_achievementLayer); Widget* scoreWidget = dynamic_cast<widget*>(m_achievementLayer->getChildByName("ImageView_231"));m_score = dynamic_cast<textatlas*>(scoreWidget->getChildByName("LabelAtlas_307"));m_score->setStringValue("45");</textatlas*></widget*></layout*>添加按钮调事件Button* startButton = dynamic_cast<button*>(m_achievementLayer->getChildByName("Button_336"));startButton->addTouchEventListener(this, toucheventselector(GameScene::touchStartButton)); </button*>利用addTouchEventListener函数绑定按钮调事件~调函数实现:void GameScene::touchStartButton(Ref* pSender, TouchEventType type){ switch (type) { case TOUCH_EVENT_ENDED: //do something break; }}