本文整理汇总了Java中javafx.animation.Timeline.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Timeline.stop方法的具体用法?Java Timeline.stop怎么用?Java Timeline.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.animation.Timeline
的用法示例。
在下文中一共展示了Timeline.stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSyncTimer
import javafx.animation.Timeline; //导入方法依赖的package包/类
public void createSyncTimer(int duration) {
covertTask = new Timeline(new KeyFrame(javafx.util.Duration.seconds(duration), (event2) -> {
timer.start();
String html = markdownParser.convertToHTML(editor.getText());
webEngine.loadContent(html);
currentHtml = html;
covertTask.stop();
editorToolBar.setActionText("Refreshed view successfully in " + timer.end() + "ms");
}));
}
示例2: startSnakeGame
import javafx.animation.Timeline; //导入方法依赖的package包/类
/**
* Starts the timeline for the snake game and monitors the snake action
*/
private void startSnakeGame() {
hasGameStarted = true;
paused = false;
timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler() {
@Override
public void handle(Event event) {
if (pressedDir != null) {
snake.setNewDirection(pressedDir);
}
snake.move();
if (snake.snakeReachedFruit(fruit)) {
snakeEatsFruit();
}
if (snake.isGameOver()) {
timeline.stop();
createGameOverPane();
}
repaintPane();
}
}), new KeyFrame(Duration.millis(speed)));
if (snake.isSnakeAlive()) {
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
}
示例3: buildEvent
import javafx.animation.Timeline; //导入方法依赖的package包/类
private EventHandler<Event> buildEvent() {
return new EventHandler<Event>() {
@Override
public void handle(Event e) {
if (turned)
return;
if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {
progressIndicator.setOpacity(1);
progressIndicator.setProgress(0);
Timeline timelineCard = new Timeline();
timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
new KeyValue(card.xProperty(), card.getX() - (initWidth * zoom_factor - initWidth) / 2)));
timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
new KeyValue(card.yProperty(), card.getY() - (initHeight * zoom_factor - initHeight) / 2)));
timelineCard.getKeyFrames().add(
new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth * zoom_factor)));
timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
new KeyValue(card.heightProperty(), initHeight * zoom_factor)));
timelineProgressBar = new Timeline();
timelineProgressBar.getKeyFrames().add(new KeyFrame(new Duration(fixationlength),
new KeyValue(progressIndicator.progressProperty(), 1)));
timelineCard.play();
timelineProgressBar.play();
timelineProgressBar.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
turned = true;
card.setFill(new ImagePattern(image, 0, 0, 1, 1, true));
card.removeEventFilter(MouseEvent.ANY, enterEvent);
card.removeEventFilter(GazeEvent.ANY, enterEvent);
if (winner) {
onCorrectCardSelected();
} else {// bad card
onWrongCardSelected();
}
}
});
} else if (e.getEventType() == MouseEvent.MOUSE_EXITED || e.getEventType() == GazeEvent.GAZE_EXITED) {
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
new KeyValue(card.xProperty(), card.getX() + (initWidth * zoom_factor - initWidth) / 2)));
timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
new KeyValue(card.yProperty(), card.getY() + (initHeight * zoom_factor - initHeight) / 2)));
timeline.getKeyFrames()
.add(new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth)));
timeline.getKeyFrames()
.add(new KeyFrame(new Duration(1), new KeyValue(card.heightProperty(), initHeight)));
timeline.play();
timelineProgressBar.stop();
progressIndicator.setOpacity(0);
progressIndicator.setProgress(0);
}
}
};
}