So i’ve implemented a highlighting box into my game (if not sure what I mean go here :point: kind of like this except in 2d) and it works perfectly if my mouse moves in a totally positive manner (+x and +y) but when I try to move my mouse in any negative (-x or -y) it won’t move. here is my code :
note: this is the rectangle class from libGDX package
com.badlogic.gdx.math.Rectangle
public static Rectangle mbounds() {
return new Rectangle(startX, startY, boxSizeX, boxSizeY);
}
start x is where the mouse was clicked first and the boxSizes are the current mouse position minus the start position
so:
boxSizeX=currentX -startX;
boxSizeY = currentY-startY;
any help would be great
btw, if anyone knows how to draw a rectangle of this kind straight from the function, please tell me thanks again
[EDIT] New Information!!! It seems that the problem may lie in the .overlaps() function because when I set a shape renderer to draw it, it drew correctly. Which means it is probably a problem with collision.
I get collision by calling:
if(mbounds().overlaps(bounds()){
//do something
}