在cocos2d源代码中将fire.png,fire.pvr,particles.png拷贝到工程中。
HelloWorldLayer.h
@interface HelloWorldLayer : CCLayer <GKAchievementViewControllerDelegate, GKLeaderboardViewControllerDelegate>
{
CCParticleSun *particleSun;
}
@property (nonatomic,retain) CCParticleSun *particleSun;
+(CCScene *) scene;
@end
HelloWorldLayer.m
@synthesize particleSun;
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
HelloWorldLayer *layer = [HelloWorldLayer node];
[scene addChild: layer];
return scene;
}
-(id) init
{
if( (self=[super init]) ) {
//CCParticleExplosion *explosion=[[CCParticleExplosion alloc] init];
//[self addChild:explosion];
//CCParticleSpiral *spiral=[[CCParticleSpiral alloc]init];
//spiral.texture=[[CCTextureCache sharedTextureCache]addImage:@"head.png"];
//[self addChild:spiral];
isTouchEnabled_=YES;
self.particleSun=[[CCParticleSun alloc]init];
[self addChild:particleSun];
}
return self;
}
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch =[touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location=[[CCDirector sharedDirector] convertToGL:location];
[particleSun runAction:[CCMoveTo actionWithDuration:1 position:location]];
// particleSun.position=location;
}