this is right?
public BEntity collide(BEntity e1, String tipo,float x, float y,float wid, float hei)
{
//hitboxWidth = Image Width, hitboxHeight = Image height.
Rectangle rectangle1 = new Rectangle(e1.x + x,e1.y + y,e1.hitboxWidth + wid,e1.hitboxHeight + hei);
for(int i = 0; i < entities.size(); i++)
{
Rectangle rectangle2 = new Rectangle(entities.get(i).x,
entities.get(i).y,entities.get(i).hitboxWidth,entities.get(i).hitboxHeight);
if(e1 != entities.get(i))
{
if(rectangle1.intersects(rectangle2))
{
if(entities.get(i).type.equals(tipo) || tipo == null)
{
return entities.get(i);
}
}
}
}
return null;
}
and the getter:
collide(this,type,-1,+4,-1,-5);
to get the entity on left