JavaFX对话-游戏

JavaFX对话-游戏,java,javafx,game-engine,Java,Javafx,Game Engine,我目前正在开发一款java游戏,该游戏由JavaFXUI支持 球员。应该能够和全国人大对话,这是没有问题的。但是我想要一个特定的文本效果。就像在polemon游戏或undertale中,文本逐字缓慢地出现 我如何才能做到这一点?我最终做到了:Timeline fiveSecondsWonder2=新的时间线(新的关键帧(持续时间.seconds(0.05),新的EventHandler(){public void handle(ActionEvent事件){textMessage.setText

我目前正在开发一款java游戏,该游戏由JavaFXUI支持

球员。应该能够和全国人大对话,这是没有问题的。但是我想要一个特定的文本效果。就像在polemon游戏或undertale中,文本逐字缓慢地出现


我如何才能做到这一点?

我最终做到了:Timeline fiveSecondsWonder2=新的时间线(新的关键帧(持续时间.seconds(0.05),新的EventHandler(){public void handle(ActionEvent事件){textMessage.setText(one.substring(0,I));;I++});fiveSecondsWonder2.setCycleCount(one.length());五秒钟精彩2.播放();}我最后这样做了:Timeline fiveSecondsWonder2=新的时间线(新的关键帧(Duration.seconds(0.05),new EventHandler(){public void handle(ActionEvent事件){textMessage.setText(one.substring(0,i));;i++;});fiveSecondsWonder2.setCycleCount(one.length());五秒钟精彩2.播放(); }
Label label = /* the label */ ;
String text = /* text to display */;

IntegerProperty lettersDisplayed = new SimpleIntegerProperty();
label.textProperty().bind(Bindings.createStringProperty(
    () -> text.substring(0, lettersDisplayed.get()),
    lettersDisplayed);

Timeline textAnimation = new Timeline(
    new KeyFrame(Duration.seconds(2), new KeyValue(lettersDisplayed, text.length()))
);