Skip to main content
Inspiring
April 18, 2009
Question

Particle System Collision Area?

  • April 18, 2009
  • 2 replies
  • 679 views

so I've got a bunch of modules called "c4" labled red1,red2,red3, etc. And a laser made from particles, with angle controlled
by bckspace and enter keys:


onEnterFrame = function(){


for (m=1;m<4;m++){
c4 = this["red"+m];  

if(robot_mc.laser_mc.lasereye_mc.hitTest(c4.cap)){c4.gotoAndPlay("frame2"); }

    //laser controls
    if(Key.isDown(Key.BACKSPACE)){robot_mc.laser_mc._visible = true; robot_mc.laser_mc.lasereye_mc._rotation -= 7;}
    if(Key.isDown(Key.ENTER)){robot_mc.laser_mc._visible = true; robot_mc.laser_mc.lasereye_mc._rotation += 7;}
    if(!Key.isDown(Key.BACKSPACE) && !Key.isDown(Key.ENTER)){robot_mc.laser_mc._visible = !true;}

    }


for(i=0;i<500;i++) {
    photons = this["photon"+i];   
    var k:MovieClip = robot_mc.laser_mc.lasereye_mc.attachMovie("photon","photon"+i ,robot_mc.laser_mc.lasereye_mc.getNextHighestDepth());
        k._xscale = Math.random()* 120 - 20;
    k._yscale = Math.random()* 180 + 35;
    k._y -= Math.random()* 10 +10;             //plus changes distance of start of beam, base changes range
        k.gotoAndPlay(Math.ceil(Math.random()*16));    }


The problem I run into is having the collision work with the beam, as opposed to the bounding box that begins with the
lasereye_mc. Is there a way to get the c4 to react with the beam, instead of the bounding box around the beam? Or a way to get the photons to interact individually? Also, is there a way to load a particle system through an onEnterFrame without it overloading/oversaturting ?    Thanks.

This topic has been closed for replies.

2 replies

shintashiAuthor
Inspiring
April 18, 2009

kglad solved the problem with the removemovieclip solution inside the particle's timeline, and the for loop inside the second for loop only needed slight modification.

kglad
Community Expert
Community Expert
April 18, 2009

you're welcome.

kglad
Community Expert
Community Expert
April 18, 2009

there are several ways to handle this, but the easiest is to keep track of those photons that are on-stage, remove the ones that are not on-stage and use a hitTest on each of the existing photons.  that will solve a number of problems that you are encountering or will encounter.

shintashiAuthor
Inspiring
April 18, 2009

"the easiest is to keep track of those photons that are on-stage"

what do you mean keep track?

"remove the ones that are not on-stage"

that's precisely what I do not know how to do. I have been unable to effect the particles of a particle system on an individual basis.

"and use a hitTest on each of the existing photons".

My previous attempt to place a for - loop inside another for loop failed. The particles still appeared but the collision detection was nonexistent.

kglad
Community Expert
Community Expert
April 18, 2009

i don't see where you're updating the photons position so i assume you're using timeline animation to move the photons.  if that's true, place the following on the last frame of the photon's timeline:

this.removeMovieClip();

and loop through all the children of the photon's parent movieclip using them in your hittest.