title: Using particle effects in cocos2d with ccspritebatchnode
body: <p>I'm trying to add a particle effect to my cocos2d iOS game. I'm having a problem when adding particles to my sprites because all of my sprites are using a spritebatch for improved performance. It seems I can't easily use a particle effect on my sprites because of this.  Everything works correctly if I simply keep all particle effects on my gameplay layer, but I'd rather have each sprite keep track of its own particle effect.  Here is my code, which is located in my player class:  </p>
  
  <pre><code>-(void)loadParticles  
  {    
      shieldParticle = [[CCParticleSystemQuad alloc] initWithFile:@"shieldParticle.plist"];
      shieldParticle.position = self.position;
      [self addChild:shieldParticle];  
  }
  </code></pre>
  
  <p>Using this technique gives me an error saying  </p>
  
  <pre><code>CCSprite only supports CCSprites as children when using CCSpriteBatchNode
  </code></pre>
  
  <p>To avoid this, I made a separate class, particleBase. </p>
  
  <p>In the particleBase class I inherit it from ccsprite and have an iVar for tracking the particle effect:  </p>
  
  <pre><code>#import "cocos2d.h"
  @interface particleBase : CCSprite
  {
  CCParticleSystem *particleEffect;
  }
  
  -(void)setParticleEffect:(NSString *)effectName;
  -(void)turnOnParticles;
  -(void)turnOffParticles;
  @end
  
  #import "particleBase.h"
  
  @implementation particleBase
  
  -(void)setParticleEffect:(NSString *)effectName
  {    
      particleEffect = [[CCParticleSystemQuad alloc] initWithFile:effectName];
      particleEffect.active = YES;
      particleEffect.position = self.position;
      [self addChild:particleEffect];
  }
  </code></pre>
  
  <p>When using this technique I tried this in my player class:  </p>
  
  <pre><code>-(void)loadParticles
  {    
      shieldParticle = [[particleBase alloc] init];
      [shieldParticle setParticleEffect:@"shieldParticle.plist"];
      [shieldParticle turnOnParticles];
      [shieldParticle setPosition:self.position];
      [self addChild:shieldParticle z:150];      
  }
  </code></pre>
  
  <p>When doing this I don't receive an error, but the particle isn't displayed either.</p>
  
  <p>Any help would be greatly appreciated.</p>