Cocos2d iphone COCOS2D粒子效应碰撞

Cocos2d iphone COCOS2D粒子效应碰撞,cocos2d-iphone,particles,Cocos2d Iphone,Particles,我不知道它为什么不起作用。粒子效果位于屏幕左下角,而不是碰撞的部分 在.H文件中 CCParticleExplosion *starsExplosion; 在.M文件中 在碰撞之下 if(distance < 30) { starsCollected += 100; [_stars removeObject:stars]; //Stars Explosion //starsExplosion.pos

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

在.H文件中

    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];
    }
if(距离<30){
星收集+=100;
[_StarsRemoveObject:stars];
//恒星爆炸
//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:StarsPlosion];
[自我清除儿童:星星清理:是];
}
我试图使用
ContentSize.Width
height=
,但运气不好。
尝试使用
Position.x
y=
,也很幸运。

您切换了x和y坐标。我知道,在你自己的代码中很难看到错误,你可能只是当时思维不清晰

更改此项:

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

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

我不认为这是你问题的根源,但你在设置位置时不是交换了x和y吗?哇,那代码真的很管用。非常感谢你。我读得不好。