Skip to Content

cocos2d custom CCSprite Class Example

Posted on

EnemySprite.h

#import <Foundation/Foundation.h>
#import "cocos2d.h"

@interface EnemySprite : CCSprite {
  int healthpoint;
}
@property (readwrite) int hp;

@end

EnemySprite.m

#import "EnemySprite.h"

@implementation EnemySprite
@synthesize hp;

-(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect
{
  if( (self=[super initWithTexture:texture rect:rect]))
  {
  }
  return self;
}
@end
EnemySprite *ep = [EnemySprite spriteWithFile:@"redbar_20x2.png"];