Ios6 如何在cocos2d中以增量方式将CCProgressTimer减少10%?
在我的应用程序中,每次我的精灵与另一个精灵碰撞时,我希望我的“健康栏”从100%减少10%。我已经把碰撞的东西弄下来了。我该怎么做?以下是my Int中创建进度计时器的代码:Ios6 如何在cocos2d中以增量方式将CCProgressTimer减少10%?,ios6,cocos2d-iphone,xcode4.5,Ios6,Cocos2d Iphone,Xcode4.5,在我的应用程序中,每次我的精灵与另一个精灵碰撞时,我希望我的“健康栏”从100%减少10%。我已经把碰撞的东西弄下来了。我该怎么做?以下是my Int中创建进度计时器的代码: CCSprite *healthFull = [CCSprite spriteWithFile:@"Health Bar.png"]; CCSprite *healthBorder = [CCSprite spriteWithFile:@"Health Bar Border.png"]; [self
CCSprite *healthFull = [CCSprite spriteWithFile:@"Health Bar.png"];
CCSprite *healthBorder = [CCSprite spriteWithFile:@"Health Bar Border.png"];
[self addChild:healthBorder z:5];
healthBorder.position = ccp(size.width / 2, 300);
health = [CCProgressTimer progressWithSprite:healthFull];
health.type = kCCProgressTimerTypeBar;
health.midpoint = ccp(1,0); // starts from right
health.barChangeRate = ccp(-1,0); // grow only in the "x"-horizontal direction
health.percentage = 100; // (0 - 100)
[self addChild:health];
health.position = ccp(size.width /2, 300);
这就是我想将进度计时器从100%递增减少10%的地方:
-(void)subtractLife{
}
-(无效)减去寿命{
健康。百分比-=10;
if(health.percentage)计划一个具有小时间延迟的函数,然后降低该函数中的百分比
-(void)subtractLife{
health.percentage-=10;
if(health.percentage<0)
health.percentage = 0;
}