@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()); } }); }
/** * Returns a composed operator that first applies the {@code this_} operator to its input, and * then applies the {@code after} operator to the result. If evaluation of either operator throws * an exception, it is relayed to the caller of the composed operator. * * @param this_ the operator to apply before the {@code after} operator is applied * @param after the operator to apply after the {@code this_} operator is applied * @return a composed operator that first applies the {@code this_} operator and then applies the * {@code after} operator * @throws NullPointerException if {@code this_} is null * @throws NullPointerException if after is null * @see #compose(LongUnaryOperator, LongUnaryOperator) */ public static LongUnaryOperator andThen( final LongUnaryOperator this_, final LongUnaryOperator after) { Objects.requireNonNull(this_); Objects.requireNonNull(after); return (long t) -> after.applyAsLong(this_.applyAsLong(t)); }
/** * Returns a composed operator that first applies the {@code before} operator to its input, and * then applies the {@code this_} operator to the result. If evaluation of either operator throws * an exception, it is relayed to the caller of the composed operator. * * @param this_ the operator to apply after the {@code before} operator is applied * @param before the operator to apply before the {@code this_} operator is applied * @return a composed operator that first applies the {@code before} operator and then applies the * {@code this_} operator * @throws NullPointerException if {@code this_} is null * @throws NullPointerException if before is null * @see #andThen(LongUnaryOperator, LongUnaryOperator) */ public static LongUnaryOperator compose( final LongUnaryOperator this_, final LongUnaryOperator before) { Objects.requireNonNull(this_); Objects.requireNonNull(before); return (long v) -> this_.applyAsLong(before.applyAsLong(v)); }