首页 > 代码库 > Cocos2d-x3.0 LoadingBar
Cocos2d-x3.0 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-x3.0 LoadingBar
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。