Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

COCOS2D Particle Effect Collision

I have no idea why it isn't working. The particle effect is located left bottom screen, instead of the part where it collided.

in .H file

    CCParticleExplosion *starsExplosion;

In .M file Under the collision

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

I tried to use the ContentSize.Width and height =, no luck. Tried to use Position.x and y =, also luck again.

like image 334
Ranbir Aulakh Avatar asked Nov 17 '25 15:11

Ranbir Aulakh


1 Answers

You switched your x and y coordinate. I know, it's hard to see the errors in your own code, you probably just weren't thinking clearly at the time.

Change this:

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

To this:

starsExplosion.position = ccp(stars.position.x, stars.position.y);
like image 130
Joe Bartelmo Avatar answered Nov 19 '25 09:11

Joe Bartelmo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!