cocos2如何使用进度条

1、创建进度条对象

//精灵背景

CCSprite *progSprite = [CCSpritespriteWithFile:@"achievePlash.png"];

//初始化进度条

CCProgressTimer *prog = [CCProgressTimerprogressWithSprite:progSprite];


2、设置进度条属性

//设置在场景中的位置

prog.position =ccp(winSize.width/2,100);

//设置进度条的类型

  prog.type =kCCProgressTimerTypeBar;

//设置进度条每次变化的x,y位移,0则不变

prog.barChangeRate =ccp(1,0);

//设置进度条起始位置,左、下、为0,右、上为1

prog.midpoint = ccp(10);

//设置当前百分比,注意,一定要设置完midpoint之后在设置percentage

prog.percentage = 50;

3、加入场景

[selfaddChild:progz:3tag:kprog];

4、调用

1、init中调用

[self scheduleUpdate]

2、update函数中

如果满足条件,则

 CCProgressTo *to = [CCProgressToactionWithDuration:timepercent:100];

[[selfgetChildByTag:kprgrunAction:to];

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值