Witam.
Zrobiłem takie wykrywanie kolizji:
public boolean isCollised(){
for(Collision c1:MyGdxGame.collisionManager.getCollisionList()){
if(!c1.equals(this)){
if(c1.overlaps(this)){
return true;
}
}
}
return false;
}
public boolean isCollOnRight(){
for(Collision c1:MyGdxGame.collisionManager.getCollisionList()){
if(!c1.equals(this)){
return this.isCollised() && (this.x + this.width >= c1.x);
}
}
return false;
}
public boolean isCollOnLeft(){
for(Collision c1:MyGdxGame.collisionManager.getCollisionList()){
if(!c1.equals(this)){
return this.isCollised() && (this.x <= c1.x + c1.width);
}
}
return false;
}
public boolean isCollOnTop(){
for(Collision c1:MyGdxGame.collisionManager.getCollisionList()){
if(!c1.equals(this)){
return this.isCollised() && (this.y + this.height >= c1.y);
}
}
return false;
}
public boolean isCollOnBottom(){
for(Collision c1:MyGdxGame.collisionManager.getCollisionList()){
if(!c1.equals(this)){
return this.isCollised() && (this.y > c1.y + c1.width);
}
}
return false;
}
Z obsługą z której strony jak widać na powyższym kodzie...
Wszystko działa, ale nie tak jak trzeba...
Wykrywa kolizje wszystkie na raz !
Proszę o pomoc, w naprawieniu kodu tak aby wykrywał kolizje tylko jedną stroną... jeżeli taka występuje.