I have trouble getting Cory's Collisiondetectionkit to work. I have installed it, and put the com
folder in a random folder where I keep all my files. It looks like this:
but I get an error when I export the code below (along with a bit more code)
Call to a possibly undefined method checkCollisions
through a reference with static type Class
This is referring to the lines that says
if(CollisionLis...
below.
This is the code which I have imported it with:
import com.coreyoneil.collision.*;
and this is where I call it in the code:
if(oCharUse == true){
if(CollisionList.checkCollisions(b1, oChar) == true){
trace("collision")
}
The folder the com
folder is located in looks like this:
You're using it wrong. The function will create an array of DisplayObjects that are colliding. For example, if b1
and oChar
are colliding, trace(CollisionList.checkCollisions()[0].name);
should trace b1
and trace(CollisionList.checkCollisions()[1].name);
should trace oChar
.
With what you're trying to achieve, you could replace
if(CollisionList.checkCollisions(b1, oChar) == true){
with
if(CollisionList.checkCollisions().indexOf(b1) && CollisionList.checkCollisions().indexOf(oChar)){