Well, this is not how to do this best I guess, this is how I do this,
hope it will be helpful:
For NetBeans -
I put images in Pictures subdirectory in /src/ directory.
Place where Main.fx source code located.
def goldenRedImages: Image =
for ( name in [
def goldenRedDX = [ 0, 0, 14, 10, 30, 14, 46, -13];
def goldenRedDY = [ 0, 0, 2, 4, 15 15, 10, 8];
DX and DY is horizontal and vertical coordinates shifts to line up pictures.
Then I define game view where this images will be seen:
def gameFieldView: Node =
x: bind 300 + goldenRedDX[ goldenRed ] + goldenRedX
y: bind 40 + goldenRedDY[ goldenRed ] + goldenRedY
image: bind goldenRedImages[ goldenRed ]
And this is all what I need to do for drawing. If I need to
change picture seen in this view only thing to do - change
variable goldenRed - because it is binded to this image view
JavaFX will take car of all drawing for me.
I should not worry about clearing previous picture, repainting
new, synchronizing it with other pictures and with screen updates…
I will only in this case change
goldenRed - which define picture for me (and shifts)
goldenRedY - Vertical coordinates
goldenRedX - Horizontal coordinates
That’s it. Once I define this GameField, I may foget about all
representation and focus on the game play itself.