Game Development Reference
In-Depth Information
}
-(void) reset;
@end
The implementation of the HealthbarComponent class is more interesting, as List-
ing 8-17 shows.
Listing 8-17. The HealthBarComponent Updates Its scaleX Property Based on the
Enemy's Remaining Hit Points
#import"HealthbarComponent.h"
#import "Enemy.h"
@implementation HealthbarComponent
-(void) onEnter
{
[super onEnter];
[self scheduleUpdate];
}
-(void) reset
{
float parentWidthHalf = self.parent.contentSize.width / 2;
float parentHeight = self.parent.contentSize.height;
float selfHeight = self.contentSize.height;
self.position = CGPointMake(parentWidthHalf, parentHeight + selfHeight);
self.scaleX = 1.0f;
self.visible = YES;
}
-(void) update:(ccTime)delta
{
if (self.parent.visible)
{
NSAssert([self.parent isKindOfClass:[Enemy class]], @"not a Enemy");
Enemy* enemy = (Enemy*)self.parent;
 
 
Search Nedrilad ::




Custom Search