Search in sources :

Example 91 with Timeline

use of javafx.animation.Timeline in project fx2048 by brunoborges.

the class GameManager method animateExistingTile.

/**
     * Animation that moves the tile from its previous location to a new location 
     * @param tile to be animated
     * @param newLocation new location of the tile
     * @return a timeline 
     */
private Timeline animateExistingTile(Tile tile, Location newLocation) {
    Timeline timeline = new Timeline();
    KeyValue kvX = new KeyValue(tile.layoutXProperty(), newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    KeyValue kvY = new KeyValue(tile.layoutYProperty(), newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    KeyFrame kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
    KeyFrame kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);
    timeline.getKeyFrames().add(kfX);
    timeline.getKeyFrames().add(kfY);
    return timeline;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Timeline (javafx.animation.Timeline)91 KeyFrame (javafx.animation.KeyFrame)87 KeyValue (javafx.animation.KeyValue)77 Rotate (javafx.scene.transform.Rotate)14 MouseEvent (javafx.scene.input.MouseEvent)13 Duration (javafx.util.Duration)13 Interpolator (javafx.animation.Interpolator)12 Insets (javafx.geometry.Insets)9 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 Scene (javafx.scene.Scene)8 ActionEvent (javafx.event.ActionEvent)7 Group (javafx.scene.Group)7 Node (javafx.scene.Node)7 KeyCode (javafx.scene.input.KeyCode)7 Color (javafx.scene.paint.Color)7 AnimationTimer (javafx.animation.AnimationTimer)6 EventHandler (javafx.event.EventHandler)6 Label (javafx.scene.control.Label)6 Rectangle (javafx.scene.shape.Rectangle)6 ArrayList (java.util.ArrayList)5