bool UILoadingBarTest_Left::init() { if (UIScene::init()) { scheduleUpdate(); CCSize widgetSize = m_pWidget->getSize(); // Add the alert UILabel *alert = UILabel::create(); alert->setText("LoadingBar left"); alert->setFontName("Marker Felt"); alert->setFontSize(30); alert->setColor(ccc3(159, 168, 176)); alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75)); m_pUiLayer->addWidget(alert); // Create the loading bar UILoadingBar* loadingBar = UILoadingBar::create(); loadingBar->setName("LoadingBar"); loadingBar->loadTexture("cocosui/sliderProgress.png"); loadingBar->setPercent(0); loadingBar->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); m_pUiLayer->addWidget(loadingBar); return true; } return false; }
bool UILoadingBarTest_Left_Scale9::init() { if (UIScene::init()) { scheduleUpdate(); CCSize widgetSize = m_pWidget->getSize(); // Add the alert UILabel *alert = UILabel::create(); alert->setText("LoadingBar left scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(20); alert->setColor(ccc3(159, 168, 176)); alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7)); m_pUiLayer->addWidget(alert); // Create the loading bar UILoadingBar* loadingBar = UILoadingBar::create(); loadingBar->setName("LoadingBar"); loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png"); loadingBar->setScale9Enabled(true); loadingBar->setCapInsets(CCRectMake(0, 0, 0, 0)); /*===*/ loadingBar->setSize(CCSizeMake(300, loadingBar->getContentSize().height)); /*=*/ loadingBar->setPercent(0); loadingBar->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); m_pUiLayer->addWidget(loadingBar); return true; } return false; }
bool UILoadingBarTest::init() { if (UIScene::init()) { scheduleUpdate(); CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add the alert UILabel *alert = UILabel::create(); alert->setText("LoadingBar"); alert->setFontName("Marker Felt"); alert->setFontSize(30); alert->setColor(ccc3(159, 168, 176)); // alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75)); m_pUiLayer->addWidget(alert); // Create the loading bar UILoadingBar* loadingBar = UILoadingBar::create(); loadingBar->setName("LoadingBar"); loadingBar->loadTexture("cocosgui/sliderProgress.png"); // loadingBar->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + loadingBar->getRect().size.height / 4.0f)); m_pUiLayer->addWidget(loadingBar); return true; } return false; }