标签:cocos2d-x extension loadingbar
.h中添加
int _count; Layout* layout; void update(float delta);
layout = Layout::create(); layout->setSize(Size(widgetSize.width, widgetSize.height)); //横向排列,这里类似Android里的线性布局 //layout->setLayoutType(LAYOUT_RELATIVE); /*以图片为背景*/ layout->setBackGroundImageScale9Enabled(true); layout->setBackGroundImage("green_edit.png"); layout->setPosition(Point(0,0)); addChild(layout); LoadingBar* loadingBar = LoadingBar::create("slider_bar_active_9patch.png"); loadingBar->setTag(0); loadingBar->setScale9Enabled(true); loadingBar->setCapInsets(Rect(0, 0, 0, 0)); loadingBar->setSize(Size(300, 23)); //设置加载方向LoadingBarTypeRight右 LoadingBarTypeLeft左 loadingBar->setDirection(LoadingBarTypeLeft); loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); layout->addChild(loadingBar); _count = 0; scheduleUpdate();
void LayoutTest::update(float delta) { _count++; if (_count > 100) { _count = 0; } LoadingBar* loadingBar = static_cast<LoadingBar*>(layout->getChildByTag(0)); loadingBar->setPercent(_count); }
标签:cocos2d-x extension loadingbar
原文地址:http://blog.csdn.net/qqmcy/article/details/24797923