2011-07-06 53 views
1

我實現粒子引擎,這裏是我的代碼:粒子引擎問題

-(id) init 
{ 
    // always call "super" init 
    // Apple recommends to re-assign "self" with the "super" return value 
    if((self=[super init])) 
    { 
     self.isTouchEnabled = YES; 
     emitter = [[CCParticleMeteor alloc] init]; 
     emitter.texture  = [[CCTextureCache sharedTextureCache] addImage:@"stars.png"]; 
     emitter.position = ccp(240, 160); 
     [self addChild:emitter]; 

    } 
    return self; 
} 
-(BOOL) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [self ccTouchesMoved:touches withEvent:event]; 
    return YES; 
} 
-(BOOL) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *myTouch = [touches anyObject]; 
    CGPoint location = [myTouch locationInView:[myTouch view]]; 
    CGPoint point  = [[CCDirector sharedDirector] convertToGL:location]; 
    emitter.position = ccp(point.x , point.y); 
    return YES; 
} 

這裏是屏幕截圖: enter image description here

這裏是我想需要:

1-我想改變效果的方向(意味着火焰向上移動,但我想向下)。

2-我想改變火焰的顏色。

如果你能幫幫.....

回答

1

1)快速瀏覽一下particle system documentatio n給出你要麼角度或重力玩 - 嘗試這些設置爲不同的值,即

emitter.angle = <the angle you want> 

2)編輯stars.png是你想要的顏色?

+0

@deanWombourne .. Thax –