Ranbir Aulakh
Ranbir Aulakh

Reputation: 98

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.

Upvotes: 3

Views: 752

Answers (1)

Joe Bartelmo
Joe Bartelmo

Reputation: 56

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);

Upvotes: 3

Related Questions