Im working on a school project and I need to get collision between an array of particles and a box, here is my current code:
for(var i : int = 0; i < particles.length; i++)
{
particles[i].update();
if(Particle.hitTestPoint(Square))
{
particle = particles.shift();
particle.destroy();
}
}
I get an error telling me that im trying to call an undefined method (hittestpoint) through a reference with static type class.
Any help would be greatly appreciated, thank!
Here is the code for the Particle.
package
{ import flash.display.*;
public class Particle
{
public var clip : DisplayObject;
public var xVel : Number = 0;
public var yVel : Number = 0;
public var drag : Number = 1;
public var gravity : Number = 0.0;
public var shrink : Number = 1;
public var fade : Number = 0;
public function Particle(symbolclass : Class, target : DisplayObjectContainer, xpos : Number, ypos : Number)
{
clip = new symbolclass();
target.addChild(clip);
clip.x= xpos;
clip.y= ypos;
}
public function update() : void
{
clip.x += xVel;
clip.y += yVel;
xVel *= drag;
yVel *= drag;
yVel+=gravity;
clip.scaleX *= shrink;
clip.scaleY *= shrink;
clip.alpha -= fade;
}
public function destroy() :void
{
clip.parent.removeChild(clip);
}
}
}
I used this tutorial for the particles, and my goal is to add collision to them