Answer the question
In order to leave comments, you need to log in
How to move window graphical objects while the cursor is in a certain position?
Hello!
To make it clear, I will add here a picture with which I explained my problem to the infidels.
On my own, I wrote the following code:
scene.setOnMouseMoved(e -> {
System.out.println(e.getX()+" "+e.getY());
if(e.getX()>750)
{
camera.cameraControlX(-0.5);
}else if(e.getX()<50)
{
camera.cameraControlX(0.5);
}
if(e.getY()>550)
{
camera.cameraControlY(-0.5);
}else if(e.getY()<50)
{
camera.cameraControlY(0.5);
}
boolean north = false, east = false, south = false, west = false;
scene.setOnMouseMoved(e -> {
if(e.getX()>750)
{
east = true;
}else if(e.getX()<50)
{
west = true;
}else{
east = false;
west = false;
}
if(e.getY()>550)
{
south = true;
}else if(e.getY()<50)
{
north = true;
}else{
north = false;
south = false;
}
});
AnimationTimer timer = new AnimationTimer() {
@Override
public void handle(long now) {
if(east)camera.cameraControlX(-0.5);
if(west)camera.cameraControlX(0.5);
if(south)camera.cameraControlY(-0.5);
if(north)camera.cameraControlY(0.5);
}
};
timer.start();
Answer the question
In order to leave comments, you need to log in
If someone is interested in how I got out of the situation, then I just created the final object. Those. the logic is as follows: if you cannot change the value of the final variable in the lambda, then the properties of the object change twice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question