1

I'm trying to make a game using JavaFX with FXML and scenebuilder. Currently I'm trying to make an event where when the user moves the player image to another image onscreen, and presses space, a small window pops up(supposed to be a shop like thing).

The problem is that the images when running in the application are different than what they are in scenebuilder. I'm assuming that in the application, I'm getting the coordinates for the picture in respect to their origin as opposed to the view it's in. Is there a way to get the coordinates in respect to the scene it's in, or am I going about this wrong?

Keanu
  • 207
  • 2
  • 3
  • 9

1 Answers1

2

Apparently, Java FX has more than one set of coordinates, which I didn't know about at the time. If you use the getX() and setX() methods, it does it in relation to where you put it in the scenebuilder. In order to get it in relation to the scene(match it to what the coordinates show in scenebuilder), you use getLayoutX() and setLayoutX().

Keanu
  • 207
  • 2
  • 3
  • 9