public static void updateAge(int age) { double rate = xrate; if (yrate < xrate) rate = yrate; if (age == 1) { Image stageI = ResManager.getImage("ph1.png"); stageLabel = new ImageView(); stageLabel.setImage(stageI); stageLabel.setScaleX(rate); stageLabel.setScaleY(rate); stageLabel.setTranslateX((stageI.getWidth() * xrate - 134) / 2.0 + 15); stageLabel.setTranslateY((stageI.getHeight() * yrate - 128) / 2.0); stageLabel.toBack(); background.toBack(); mbg.root.getChildren().add(stageLabel); stageLabel.setX(0); stageLabel.setY(0); Timeline tl = new Timeline( new KeyFrame( Duration.seconds(0), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0)), new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } else if (age == 2) { GUIManager.bgMusic.stop(); GUIManager.bgMusic = ResManager.getAudio("age2.mp3"); GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE); GUIManager.bgMusic.setVolume(GUIManager.volumn); GUIManager.bgMusic.play(); final Image stageII = ResManager.getImage("ph2.png"); EventHandler<ActionEvent> act = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { stageLabel.setImage(stageII); } }; Timeline tl = new Timeline( new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)), new KeyFrame(Duration.seconds(1), act), new KeyFrame( Duration.seconds(2), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } else if (age == 3) { GUIManager.bgMusic.stop(); GUIManager.bgMusic = ResManager.getAudio("age3.mp3"); GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE); GUIManager.bgMusic.setVolume(GUIManager.volumn); GUIManager.bgMusic.play(); final Image stageIII = ResManager.getImage("ph3.png"); EventHandler<ActionEvent> act = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { stageLabel.setImage(stageIII); } }; Timeline tl = new Timeline( new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)), new KeyFrame(Duration.seconds(1), act), new KeyFrame( Duration.seconds(2), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } }