I do not completely understand your problem, I have just written a small working example for a Left -> Right Bar Type Progress Bar
- (void) onEnter
{
[super onEnter];
CCSprite *sprite = [CCSprite spriteWithImageNamed:@"emma.png"];
_progressNode = [CCProgressNode progressWithSprite:sprite];
_progressNode.type = CCProgressNodeTypeBar;
_progressNode.midpoint = ccp(0.0f, 0.0f);
_progressNode.barChangeRate = ccp(1.0f, 0.0f);
_progressNode.percentage = 0.0f;
_progressNode.positionType = CCPositionTypeNormalized;
_progressNode.position = ccp(0.5f, 0.5f);
[self addChild:_progressNode];
self.userInteractionEnabled = YES;
}
- (void) touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
_progressNode.percentage += 10.0f;
}
Notice that the CCSprite
is not added to the scene, you can't use SpriteBuilder
for that one I'm afraid. (Unless you want to remove it from the parent but that gets a little messy)
Also, do all the setup before you call the percentage setter.
And the percentage
is actually a double
. Always check to make sure that there are no casting problems happening.