//get root node from json file
CCNode *rootNode = cocostudio::timeline::NodeReader::getInstance()->createNode("UITest_1.json");
this->addChild(rootNode);
//iterate children and find target by tag
for (int i = 0; i < rootNode->getChildrenCount(); i++) {
Widget *child = static_cast<Widget *>(rootNode->getChildren()->objectAtIndex(i));
if (child) {
UIButton *button = static_cast<UIButton *>(UIHelper::seekWidgetByTag(child, 10086));
button->addTouchEventListener(this, toucheventselector(HelloWorld::battleEvent));
UIButton *itemButton = static_cast<UIButton *>(UIHelper::seekWidgetByTag(child, 10090));
itemButton->addTouchEventListener(this, toucheventselector(HelloWorld::battleEvent));
UIImageView *imageView = static_cast<UIImageView *>(UIHelper::seekWidgetByTag(child, 10089));
imageView->setColor(ccc3(255, 0, 0));
}
}
cocos2d-x 2.2.5 cocostudio
最新推荐文章于 2015-09-26 09:00:47 发布