Moving Camera With Right Click Mouse Option
Apparently there's already an existing function using the scrollwheel which I wasn't aware of prior to this code.
Going to leave it here for any type of reference.
declare
Code:
public boolean rightClickDown = false;
public int rightClickX;
public int rightClickY;
in
Code:
public final void mouseDragged(MouseEvent e) {
add
Code:
if (SwingUtilities.isRightMouseButton(e)) {
if (rightClickX == -1) {
rightClickX = x;
}
if (rightClickY == -1) {
rightClickY = y;
}
rightClickDown = true;
if (x > rightClickX) {
keyArray[1] = 1;
}
if (x < rightClickX) {
keyArray[2] = 1;
}
if (y > rightClickY) {
keyArray[3] = 1;
}
if (y < rightClickY) {
keyArray[4] = 1;
}
}
in
Code:
public final void mouseReleased(MouseEvent e) {
add
Code:
if (rightClickDown) {
rightClickDown = false;
for (int i = 0; i < 5; i++) {
keyArray[i] = 0;
}
rightClickX = -1;
rightClickY = -1;
}