首页 > 代码库 > Cocos2d-X加载UI Editor
Cocos2d-X加载UI Editor
Layer* uiLayer = Layer::create(); myLayout = dynamic_cast<ui::Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("enter/enter_1.json")); uiLayer->addChild(myLayout); uiLayer->setPosition(250, 400); sprite->addChild(uiLayer, 12);
1.加载进度条
HelloScene.cpp
loadingBar = dynamic_cast<LoadingBar*>(myLayout->getChildByTag(1)); loadingBar->setPercent(0); this->schedule(schedule_selector(HelloWorld::runningSchedule));
进度条回调
void HelloWorld::runningSchedule(float dt){ int prc = loadingBar->getPercent() + 1; if (prc == 100) { auto reScene = TransitionCrossFade::create(1.0, GameLogin::createScene());//当进度条满时进入下一场景 Director::getInstance()->setDepthTest(false); Director::getInstance()->replaceScene(reScene); } loadingBar->setPercent(prc);}
2.加载按钮
Button* startBtn = dynamic_cast<Button*>(myLayout->getChildByTag(4)->getChildByTag(69)); startBtn->addTouchEventListener(this, toucheventselector(GameLogin::touchButton));
按钮回调
void HelloWorld::touchButton(Object* obj, TouchEventType eventType){ auto button = dynamic_cast<Button*>(obj); int tag = button->getTag(); switch (eventType) { case TouchEventType::TOUCH_EVENT_BEGAN: break; }}
Cocos2d-X加载UI Editor
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。