Grab the following image: http://i.stack.imgur.com/O5DRf.png. It is 2x30. I want to make a bar that is 15 pixels high. Normally, the dimensions would be 1x15, but since I assume you're working with retina display, we have to double such dimensions to 2x30.
Create a CCSprite with it, and set the anchor point to ccp(0.0,0.5):
CCSprite *bar = [CCSprite spriteWithFile:@"MyBar.png"];
bar.position = ccp(240,160);
bar.anchorPoint = ccp(0.0,0.5);
Now the question is, how long (max) is the health bar? Let us say it is 200 pixels long. Therefore, 100% = 200 pixels long. Let us set it to 200 pixels long then:
bar.scaleX = 200
So, how about 50% of health? Then, clearly, the property .scaleX
should be 100.
bar.scaleX = 100
That is pretty much all you might need to create a simple bar quickly.