标签:style blog io color ar os sp div on
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; } }
标签:style blog io color ar os sp div on
原文地址:http://www.cnblogs.com/Susake/p/4088593.html