I am working on educational klondike game project with JavaFX. What I am trying to do is to create dynamic scaling of whole game.
I used scale class to do so. It seems almost good, as it change the scale of all interface elements, apart of the background, which is a bit smaller then the actual window.
I already tried to manipulate with BackgroundSize, but it doesn't make any change. How can I fix it?
Thanks a lot for Your help!
I add pictures to show the problem:
public class Klondike extends Application {
private static final double WINDOW_WIDTH = 1400;
private static final double WINDOW_HEIGHT = 900;
Button changeThemeButton;
Button newGame;
Button undo;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
startGame(primaryStage);
}
public void startGame(Stage primaryStage){
Card.loadCardImages();
Game game = new Game();
game.setTableBackground(new Image(Common.loadThemeSettings().get(0)));
initializeButtons(game, primaryStage);
primaryStage.setTitle("Klondike Solitaire");
primaryStage.setScene(new Scene(game, WINDOW_WIDTH, WINDOW_HEIGHT));
// SCALLING:
Scale scale = new Scale(1, 1);
scale.xProperty().bind(game.widthProperty().divide(WINDOW_WIDTH));
scale.yProperty().bind(game.heightProperty().divide(WINDOW_HEIGHT));
game.getTransforms().add(scale);
primaryStage.setResizable(true);
// SCALLING END:
primaryStage.show();
}
BACKGROUND PICTURE:
public void setTableBackground(Image tableBackground) {
setBackground(new Background(new BackgroundImage(tableBackground,
BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT,
BackgroundPosition.CENTER, BackgroundSize.DEFAULT)));
}