S
SpiceEdge
Guest
My code is supposed to draw a white rectangle and an orange rectangle on top. The white rectangle is supposed to get bigger in the y-direction when you hover over it, and go back to normal when you stop hovering over it. But when not hovering over the rectangles, the white rectangle doesn't seem to go back to normal, even though im clearly using "resize -= resizeSpeed;" with resizeSpeed being a constant.
This is my code:
The variable "touchingRectangles" is a variable that is true or false depending on if you're hovering over the rectangles and is set in another object. It's like a function that checks if you're hovering over the rectangle. This variable is not the problem as the rectangle clearly gets bigger if you're hovering over it, so the "function" that checks for the hover clearly works (And I'm just using an "else" for if the mouse isn't hovering so it can't be the check for "when not hovering" in said "function" that is working incorrectly)
Does anyone know what the problem is? I don't see any problem in the code so I don't know if you're going to find one either.
This is my code:
GML:
resizedBottomYPos = bottomYPos + clamp(resize, 0, (2 * global.theoryRectangleHeight));
if (touchingRectangles) {
resize += resizeSpeed;
draw_rectangle_color(leftXPos, topYPos, rightXPos, resizedBottomYPos, c_white, c_white, c_white, c_white, false);
draw_rectangle_color(leftXPos, topYPos, rightXPos, bottomYPos, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, false);
} else {
if (resize > 0) {
resize -= resizeSpeed;
draw_rectangle_color(leftXPos, topYPos, rightXPos, resizedBottomYPos, c_white, c_white, c_white, c_white, false);
draw_rectangle_color(leftXPos, topYPos, rightXPos, bottomYPos, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, false);
} else {
resize = 0;
draw_rectangle_color(leftXPos, topYPos, rightXPos, bottomYPos, c_white, c_white, c_white, c_white, false);
draw_rectangle_color(leftXPos, topYPos, rightXPos, bottomYPos, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, global.theoryRectangleColor, false);
}
}
Does anyone know what the problem is? I don't see any problem in the code so I don't know if you're going to find one either.