Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorgraxbishop
    • CommentTimeAug 25th 2011
     
    Hi there. I'm very new to this framework and I'm trying to understand how collisions work. I am trying to get some code to work, using Flinteroids (http://old-wp.slekx.com/2009/12/flinteroids-advanced-flint-tutorial/) as a starting point. I've hit a wall and I don't know what to do next.

    I have created two particles on the stage using ImageClass that are added to two different InitializerGroup classes (ParticleA and ParticleB). I have set their velocities to some random value and I have set ParticleA to TurnTowardsMouse.

    This is what I want to do. I want ParticleA and ParticleB to collide with each other. When this happens I want ParticleA to die and ParticleB to stop moving for 2 seconds, then continue with its path. In the future I want to change ParticleB so that it becomes "safe" for other ParticleA to collide with during those 2 seconds.

    So far I am detecting the collision using ParticleEvent.PARTICLES_COLLISION, then I am removing ParticleA. And then ParticleB "bounces" off the collision and carrys on moving.

    Any advice would be greatly appreciated.

    Cheers,

    Grax
    • CommentAuthorRichard
    • CommentTimeSep 27th 2011
     
    Hi

    If you set up a second emitter with the behaviour you want for ParticleB after the collision. Then, when the collision occurs, remove ParticleB fron the current emitter and add it to the new emitter. It then won't be involved in any collisions and won't jave the behaviours the original emitter gave it.

    The new emitter will need to set the lifetime of the particle to 2 seconds so you can listen for it to die. When it dies, you revive it and return it to the original emitter where it can resume what it was doing.

    The Logo Tween example moves particles from one emitter to another to alter their behaviour.

    Richard