use of javafx.animation.ScaleTransition in project fx2048 by brunoborges.
the class GameManager method animateMergedTile.
/**
* Animation that creates a pop effect when two tiles merge
* by increasing the tile scale to 120% at the middle, and then going back to 100%
* @param tile to be animated
* @return a sequential transition
*/
private SequentialTransition animateMergedTile(Tile tile) {
final ScaleTransition scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
scale0.setToX(1.2);
scale0.setToY(1.2);
scale0.setInterpolator(Interpolator.EASE_IN);
final ScaleTransition scale1 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
scale1.setToX(1.0);
scale1.setToY(1.0);
scale1.setInterpolator(Interpolator.EASE_OUT);
return new SequentialTransition(scale0, scale1);
}
use of javafx.animation.ScaleTransition in project Board-Instrumentation-Framework by intel.
the class RadialMenu method click.
public void click(final RadialMenuItem CLICKED_ITEM) {
List<Transition> transitions = new ArrayList<>(items.size() * 2);
for (Parent node : items.keySet()) {
if (items.get(node).equals(CLICKED_ITEM)) {
// Add enlarge transition to selected item
ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
enlargeItem.setToX(5.0);
enlargeItem.setToY(5.0);
enlargeItem.setOnFinished(event -> {
node.setScaleX(1.0);
node.setScaleY(1.0);
});
transitions.add(enlargeItem);
} else {
// Add shrink transition to all other items
ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
shrinkItem.setToX(0.0);
shrinkItem.setToY(0.0);
transitions.add(shrinkItem);
}
// Add fade out transition to every node
FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
fadeOutItem.setToValue(0.0);
fadeOutItem.setOnFinished(event -> {
node.setTranslateX(0);
node.setTranslateY(0);
});
transitions.add(fadeOutItem);
}
// Add rotate and fade transition to main menu button
if (options.isButtonHideOnSelect()) {
RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
rotateMainButton.setToAngle(225);
transitions.add(rotateMainButton);
FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
fadeOutMainButton.setToValue(0.0);
transitions.add(fadeOutMainButton);
ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
shrinkMainButton.setToX(0.0);
shrinkMainButton.setToY(0.0);
transitions.add(shrinkMainButton);
} else {
RotateTransition rotateBackMainButton = new RotateTransition();
rotateBackMainButton.setNode(cross);
rotateBackMainButton.setToAngle(0);
rotateBackMainButton.setDuration(Duration.millis(200));
rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
transitions.add(rotateBackMainButton);
FadeTransition mainButtonFadeOut = new FadeTransition();
mainButtonFadeOut.setNode(mainMenuButton);
mainButtonFadeOut.setDuration(Duration.millis(100));
mainButtonFadeOut.setToValue(options.getButtonAlpha());
transitions.add(mainButtonFadeOut);
}
// Play all transitions in parallel
ParallelTransition selectTransition = new ParallelTransition();
selectTransition.getChildren().addAll(transitions);
selectTransition.play();
// Set menu state back to closed
setState(State.CLOSED);
mainMenuButton.setOpen(false);
}
use of javafx.animation.ScaleTransition in project fx2048 by brunoborges.
the class GameManager method animateNewlyAddedTile.
/**
* Animation that creates a fade in effect when a tile is added to the game
* by increasing the tile scale from 0 to 100%
* @param tile to be animated
* @return a scale transition
*/
private ScaleTransition animateNewlyAddedTile(Tile tile) {
final ScaleTransition scaleTransition = new ScaleTransition(ANIMATION_NEWLY_ADDED_TILE, tile);
scaleTransition.setToX(1.0);
scaleTransition.setToY(1.0);
scaleTransition.setInterpolator(Interpolator.EASE_OUT);
scaleTransition.setOnFinished(e -> {
if (this.gameGrid.values().parallelStream().noneMatch(Objects::isNull) && mergeMovementsAvailable() == 0) {
board.setGameOver(true);
}
});
return scaleTransition;
}
Aggregations