【问题标题】:Particle engine problem粒子引擎问题
【发布时间】:2011-07-06 09:31:06
【问题描述】:

我正在实现粒子引擎,这是我的代码:

-(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;
}

这是屏幕截图:

这是我想要的:

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

2-我想改变火焰的颜色。

如果可以的话请帮忙.....

【问题讨论】:

    标签: iphone cocos2d-iphone particles


    【解决方案1】:

    1) 快速查看particle system documentation 可以让您使用角度或重力 - 尝试将它们设置为不同的值,即

    emitter.angle = <the angle you want>
    

    2) 编辑 stars.png 为您想要的颜色?

    【讨论】:

      猜你喜欢
      • 2011-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      • 2021-07-12
      相关资源
      最近更新 更多