Search in sources :

Example 81 with KeyValue

use of javafx.animation.KeyValue 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

KeyValue (javafx.animation.KeyValue)81 KeyFrame (javafx.animation.KeyFrame)79 Timeline (javafx.animation.Timeline)78 Interpolator (javafx.animation.Interpolator)12 Rotate (javafx.scene.transform.Rotate)12 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 MouseEvent (javafx.scene.input.MouseEvent)9 Duration (javafx.util.Duration)9 ArrayList (java.util.ArrayList)8 Insets (javafx.geometry.Insets)8 Scene (javafx.scene.Scene)7 Group (javafx.scene.Group)6 Node (javafx.scene.Node)6 KeyCode (javafx.scene.input.KeyCode)6 StackPane (javafx.scene.layout.StackPane)6 VBox (javafx.scene.layout.VBox)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 AnimationTimer (javafx.animation.AnimationTimer)5 ActionEvent (javafx.event.ActionEvent)5 PointLight (javafx.scene.PointLight)5