@PostConstruct private void init() { controlPane.addEventHandler( MouseEvent.MOUSE_CLICKED, event -> { if (Objects.equals(event.getButton(), MouseButton.PRIMARY)) { play(); } }); controlPane.addEventHandler( KeyEvent.KEY_TYPED, event -> { if (Objects.equals(event.getCode(), KeyCode.UP)) { play(); } }); twoPipePane .approachingTwoPipeProperty() .addListener( (observable, oldValue, newValue) -> { if (Objects.nonNull(newValue) && Objects.nonNull(oldValue)) { scoreBoard.setScore(scoreBoard.getScore() + 1); } }); scoreBoard .scoreProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue.intValue() % 5 == 0 && newValue.intValue() <= 250) { twoPipePane.setPipeTransitionSpeed(twoPipePane.getPipeTransitionSpeed() + 0.1); twoPipePane.setBySoar(twoPipePane.getBySoar() - 0.65); twoPipePane.setByFall(twoPipePane.getByFall() + 0.65); } }); twoPipePane .playableProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { scoreBoard.setScore(0); } else { twoPipePane.setPipeTransitionSpeed(1); twoPipePane.setBySoar(-65); twoPipePane.setByFall(twoPipePane.getScene().getHeight()); } }); }