标签:附加 mono name cas 获取 start 代码 art from
须要包括的头文件及名字空间:
获取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");
Button* startButton = dynamic_cast<Button*>(m_achievementLayer->getChildByName("Button_336")); startButton->addTouchEventListener(this, toucheventselector(GameScene::touchStartButton));
回调函数实现:
void GameScene::touchStartButton(Ref* pSender, TouchEventType type) { switch (type) { case TOUCH_EVENT_ENDED: //do something break; } }
Cocos2d-x3.0 从代码中获取cocostudio编辑的UI控件
标签:附加 mono name cas 获取 start 代码 art from
原文地址:http://www.cnblogs.com/yfceshi/p/6937014.html