COCOS2D粒子效应碰撞

时间:2012-12-30 14:41:35

标签: cocos2d-iphone particles

我不知道它为什么不起作用。粒子效果位于左下方的屏幕,而不是它碰撞的部分。

<。>文件中的

    CCParticleExplosion *starsExplosion;

在.M档案中 在碰撞下

        if(distance < 30) {
        starsCollected += 100;
        [_stars removeObject:stars];

        //Stars Explosion
        //starsExplosion.position = ccp(stars.contentSize.width, stars.contentSize.height);
        starsExplosion = [[CCParticleExplosion alloc] init];
        starsExplosion.position = ccp(stars.position.y, stars.position.x);
        starsExplosion.texture = [[CCTextureCache sharedTextureCache] addImage:@"star-icon.png"];

        [self addChild:starsExplosion];

        [self removeChild:stars cleanup:YES];
    }

我尝试使用ContentSize.Widthheight =,没有运气。 试图使用Position.xy =,再次运气。

1 个答案:

答案 0 :(得分:3)

您切换了x和y坐标。我知道,很难看到你自己的代码中的错误,你当时可能只是没有想清楚。

改变这个:

starsExplosion.position = ccp(stars.position.y, stars.position.x);

对此:

starsExplosion.position = ccp(stars.position.x, stars.position.y);
相关问题