Permalink
Browse files

emitter embedded

  • Loading branch information...
1 parent cf1817a commit f649ebeed3af4b21e3d698863726afbc3c605408 @fmemon committed Apr 9, 2012
Showing with 23 additions and 1 deletion.
  1. +5 −1 Alif/Box.h
  2. +18 −0 Alif/Box.m
View
@@ -22,15 +22,19 @@
int score;
int highscore;
+ CCParticleExplosion *myEmitter;
+
}
@property(nonatomic, retain) CCLayer *layer;
@property(nonatomic, readonly) CGSize size;
@property(nonatomic) BOOL lock;
-(id) initWithSize: (CGSize) size factor: (int) factor;
-(Tile *) objectAtX: (int) posX Y: (int) posY;
--(BOOL) check;
-(int) scored;
-(void) unlock;
-(void) removeSprite: (id) sender;
-(void) afterAllMoveDone;
+-(void)callEmitter: (id) sender;
+
+
@end
View
@@ -119,6 +119,8 @@ -(int) scored {
-(void) removeSprite: (id) sender{
[MusicHandler playPing];
+ [self callEmitter:sender];
+
[layer removeChild: sender cleanup:YES];
score +=5;
[(CCLabelTTF*)[layer getChildByTag:99] setString:[NSString stringWithFormat:@" Score: %i",score]];
@@ -192,4 +194,20 @@ -(int) repairSingleColumn: (int) columnIndex{
return extension;
}
+-(void)callEmitter: (id) sender{
+ int numParticle = 30 +CCRANDOM_0_1()*100;
+ myEmitter = [[CCParticleExplosion alloc] initWithTotalParticles:numParticle];
+ myEmitter.texture = [[CCTextureCache sharedTextureCache] addImage:@"goldstars1sm.png"];
+ CCSprite* sprite = (CCSprite*)sender;
+ // NSLog(@"Value of x %f and y %f", sprite.position.x, sprite.position.y);
+ myEmitter.position = CGPointMake(sprite.position.x, sprite.position.y);
+ myEmitter.life =0.2f + CCRANDOM_0_1()*0.1;
+ myEmitter.duration = 0.1f + CCRANDOM_0_1()*0.05;
+ myEmitter.scale = 0.5f;
+ myEmitter.speed = 50.0f + CCRANDOM_0_1()*50.0f;
+ myEmitter.blendAdditive = YES;
+ [layer addChild:myEmitter z:11];
+ myEmitter.autoRemoveOnFinish = YES;
+}
+
@end

0 comments on commit f649ebe

Please sign in to comment.