加载进度条

本文介绍如何利用Cocos2d-x库创建一个加载进度条。通过加载‘loading.png’作为进度条的基础,设置进度类型为水平条,并使用'loadbg.png'作为背景。通过设置进度变化率和位置,实现从左到右的动画效果,展示10秒完成100%的加载过程。
摘要由CSDN通过智能技术生成
loading=CCSprite::create("loading.png");
pro=CCProgressTimer::create(loading);
loadingbar=CCSprite::create("loadbg.png");


pro->setType(kCCProgressTimerTypeBar);
//    Setup for a bar starting from the left since the midpoint is 0 for the x
pro->setMidpoint(ccp(0,0));
//    Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
pro->setBarChangeRate(ccp(1, 0));




w=loadingbar->getTexture()->getContentSize().width;
h=loadingbar->getTexture()->getContentSize().height;
x=w/2+((AppDelegate::SCREEN_WIDTH-w)/2);
to= CCProgressTo::create(10, 100);
pro->setPosition(ccp(x,h));
action=CCRepeatForever::create(to);
pro->runAction(action);
loadingbar->setPosition(ccp(x,h));
//loading->setPosition(ccp(x,h));
sprite->setAniPosition(sprite->sprite,x+15-w/2,h);
this->addChild(loadingbar);
// this->addChild(loading);
this->addChild(pro);
this->addChild(sprite);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值