私はプログレスバーを使用して、プレーヤーの特定のステータスのレベルをプレーヤーに知らせるゲームを持っています。たとえば空腹で、ゼロから始まり、ゆっくりと最大のバーになります。彼が食べると飢えが減る。cocos2dの進行状況バーを正しく更新する方法は?
私はprogressBarとして実装しようとしましたが、バーが両方の方法を拡張するので間違った動作をします。片側のみを拡張する必要があります。また、アクションを使用するので、バーを設定するのに苦労しました。
簡単な方法はありますか?
私はクラスPetを持っていて、空腹があります(0-100)。私はバーに飢えを見せたい。
hungerBar = [CCSprite spriteWithFile:@"redbar.png"];
CCLabelTTF *hungerLabel = [CCLabelTTF labelWithString:@"Hunger:" fontName:@"Helvetica" fontSize:25];
[hungerLabel setColor:ccc3(255, 255, 255)];
// CGPoint temp = ccp(250, 300);
// hungerBar.position = temp;
// [self addChild:hungerBar];
CGPoint temp2 = ccp(250, 320);
[hungerLabel setPosition:temp2];
[self addChild:hungerLabel];
CCSprite *bar = [CCSprite spriteWithFile:@"redbar.png"];
powerBar= [CCProgressTimer progressWithSprite:bar];
powerBar.type = kCCProgressTimerTypeBar;
powerBar.position = ccp(-30, -10);
powerBar.anchorPoint = ccp(0, 0);
powerBar.percentage = 20; // (0 - 100)
[hungerLabel addChild:powerBar];
ソースが追加されました。
進行状況を示すことができますか? –