PDA

View Full Version : Check textures overlaping



kaufenpreis
12-22-2014, 06:44 AM
Hey i am writing a game when there are bunch of textures that changes locations, but i want to check that they are not drawing over other textures, i tried to write a code for chceking it but its not working well.

Here is the code i tried:

circles.setPosition(new Vector2(r.nextInt(width-height/8*2)+height/8,
r.nextInt(height-height/8*2)+height/8),
i);

circl[i].set((float) (circles.getPosition(i).x+height/16),
(float) (circles.getPosition(i).y+height/16),
height/16);

while(isLaping = true){

System.out.println("in");

for(int y = 0; y < circlesArray.length-1; y++){

if(Intersector.overlaps(circl[y], circl[y+1])){

circles.setPosition(new Vector2(r.nextInt(width-height/8*2)+height/8,
r.nextInt(height-height/8*2)+height/8),
i);

circl[i].set((float) (circles.getPosition(i).x+height/16),
(float) (circles.getPosition(i).y+height/16),
height/16);
}else{
isLaping = false;
}
}
}
Anyone has an idea to fix it?