Author Topic: [SOLVED] FlxEmitter particles collisions not working  (Read 1976 times)

Daranus

  • Member
  • **
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Normally I wouldnt wanna make a thread for every question, but I guess it's the right way as others can find an answer  more easily when they search like this.

So, here we go again. Like the title suggests, I cannot get particles from a FlxEmitter to collide with the floor.

I tried to set it within the collide: parameter when initializing with the values 0,1,2,10 and nothing really helped me.

After that i tried to get it with the FlxU collideObject function but that didnt help either.

Any suggestions?

Tyvm for any hints again and have a nice weekend,
Daranus
« Last Edit: Fri, Jul 8, 2011 by Daranus »

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: FlxEmitter particles collisions not working
« Reply #1 on: Fri, Jul 8, 2011 »
Making a new thread for each problem is actually a good thing. It should make it easier for people new to Flixel to find out more about the individual issues.

Here's how you make particles collide:

Declare your particles:

Code: [Select]
    // big gibs
    _bigGibs = [[FlxEmitter alloc] init];
    _bigGibs.delay = 0.02/3;
    _bigGibs.minParticleSpeed = CGPointMake(-200,
                                            200);
    _bigGibs.maxParticleSpeed = CGPointMake(200,
                                            0);
    _bigGibs.minRotation = -720;
    _bigGibs.maxRotation = 720;
    _bigGibs.gravity = 200;
    _bigGibs.particleDrag = CGPointMake(0, 0);
    _bigEmitter = [_bigGibs retain];
    [_bigGibs createSprites:ImgSpawnerGibs quantity:20 bakedRotations:NO
                   multiple:YES collide:1.0 modelScale:1.0];

Then in your update function:

Code: [Select]
    for (FlxObject * s in _bigGibs.members) {
        [FlxU collideObject:s withGroup:_blocks];

    }

This will slow down your game. Just 20 particles colliding slows Mode down to 12-15 fps.

Also it seems to only pick the first sprite on your sprite sheet as soon as you set collide to 1.0.

Good luck!
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

Daranus

  • Member
  • **
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: FlxEmitter particles collisions not working
« Reply #2 on: Fri, Jul 8, 2011 »
Works! I missed the for...members part.

Looks veeery awkward because they are not bouncing but sliding on the surface like crazy but i guess i have to look more closely how canabalt did it.

Thanks again and see ya on my next question,
Daranus