【发布时间】:2019-02-25 23:53:37
【问题描述】:
我尝试将背景大小设为窗口大小。 但是,它很挑剔。我没有使用css文件格式。
主要是实现窗口的部分。
public void start(Stage primaryStage) throws Exception {
GameLoopManager loop = GameLoopManager.instance();
Controller controller = new Controller(loop, primaryStage);
loop.start(new MenuState());
primaryStage.show();
primaryStage.setFullScreen(true);
}
这是实现背景和舞台的body部分。
private UISubScene optionSubScene;
private UISubScene helpSubScene;
private UISubScene creditsSubScene;
private UISubScene buttonChooserScene;
private UISubScene sceneToHide;
List<UIButton> menuButtons;
List<ButtonPicker> buttonsList;
private BUTTON chosenButton;
public MenuViewManager(Stage mainStage) {
sound.backgroundMusic();
menuButtons = new ArrayList<>();
mainPane = new AnchorPane();
mainScene = new Scene(mainPane);
mainScene.setFill(null);
mainStage.setScene(mainScene);
super.mainStage = mainStage;
createSubScenes();
createButtons();
createBackground();
createLogo();
super.mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
controller.stop();
}
});
// mainStage.show();
}
private void createBackground() {
Image backgroundImgae = new Image("main/resources/images/jxoPOUxa.gif",true);
BackgroundImage background = new BackgroundImage(backgroundImgae, BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
mainPane.setBackground(new Background(background));
}
我厌倦了使用 BackgroundSize.AUTO,但是我不能。 我该怎么做才能得到解决方案?
如果,我可以用css格式怎么用呢?但是我不能重写和修改很多代码,因为我的代码快完成了,我正在集成和调试。
【问题讨论】: