我有一个游戏,使用进度条通知玩家某些属性的水平。例如饥饿,当它从零开始,慢慢增加到最大值。当他吃饥饿减少。如何制作并正确更新cocos2d中的进度条?
我尝试作为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];
新增来源。
你能够显示你的progressBar代码吗? – 2012-08-11 07:13:21