プログレスバーを使用して、プレーヤーの特定の統計のレベルをプレーヤーに通知するゲームがあります。たとえば、飢えがゼロから始まり、ゆっくりと最大バーまで加算されます。彼が食べると空腹が減ります。
私はprogressBarとして実装しようとしましたが、バーが両方向に拡大し、片側だけを拡大する必要があるため、うまくいきません。また、アクションを使用するため、バーを設定するのに苦労しました。
それを行う簡単な方法はありますか?
私はペットのクラスを持っていて、それは空腹(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];
ソースを追加しました。