Name: Anonymous 2012-12-17 6:09
Help me out. I'm having trouble with 2 Dimensional collision detection in ActionScript 3.
public function isCollidingWithObject (other : GameObject) : Boolean
{
return ( Math.abs((this.position.x + (this.width / 2)) - (other.position.x + (other.width / 2) )) <= this.width + other.width
&& Math.abs((this.position.y + (this.height / 2)) - (other.position.y + (other.height / 2) )) <= this.height + other.height);
}
Why the fuck doesn't this work, I don't understand.
It keeps colliding 40 pixels too early.
public function isCollidingWithObject (other : GameObject) : Boolean
{
return ( Math.abs((this.position.x + (this.width / 2)) - (other.position.x + (other.width / 2) )) <= this.width + other.width
&& Math.abs((this.position.y + (this.height / 2)) - (other.position.y + (other.height / 2) )) <= this.height + other.height);
}
Why the fuck doesn't this work, I don't understand.
It keeps colliding 40 pixels too early.