1
1パーセントを表す複数のイメージを整列させて、独自のヘルスインジケータを作成したいと考えています。基本的に、現在の健康状態に基づいて、私は必要に応じて1パーセントのパーツを整列させます。しかし、それらを削除することは問題であるようです。独自のヘルス・インジケーターに関する問題。 Cocos2d
-(void)updateHealthIndicator:(ccTime)delta{
//getting health and healthReduction (removed for better readability). This part does not affect the functioning of the loop...
if(health-healthReduction > 0){
NSLog(@"updatehealthindicator called ! health = %d ", health);
health -= healthReduction;
[self removeChildByTag:1000 cleanup:YES];
for (int i = health; i>0; i--){
onePercent = [CCSprite spriteWithFile:@"onepercentofhi.png"];
onePercent.anchorPoint = ccp(0,0);
onePercent.position = ccp(880+(-onePercent.contentSize.width) * i,712);
[self addChild:onePercent z:2 tag:1000];
}
}
ヘルスインジケータが現れ、それだけで最初の「1パーセント」の部分を削除しているようです。タグ1000のすべてのスプライトがこの[self removeChildByTag:1000 cleanup:YES];
の影響を受けていますか?
コードが動作します!本当にありがとう !!! –