2

i have a problem with the Translate Transitions. I have a GridPane 7x7. In each cell there is a StackPane. Each StackPane has 3 ImageViews. If i want to change the position of the last added ImageView with a Translate Transition it moves but it moves under the other ImageViews. What do i have to do to keep it up top while the animation is running? It actually stays above if the animation goes up or left but not down and right.

TranslateTransition translate = new TranslateTransition(new Duration(animation_duration));
        translate.setToX(100);
        translate.setByY(100);

        translate.setNode(players[old_x][old_y]);
        translate.play();

Thanks

  • 1
    [mcve] please .. and stick to java naming conventions when showing code publicly – kleopatra Jan 30 '21 at 13:16
  • Call `players[oldX][oldY].toFront()` before starting the animation. – James_D Jan 30 '21 at 16:08
  • 2
    Note that @James solution will probably work for some layouts (e.g. `GridPane`, `StackPane`, etc.) where the order of the children don't determine their position. But be careful if you're using a layout where the order of children actually do determine their position (e.g. `HBox`, `VBox`, etc.). In those cases it would be better to manipulate the `Node.viewOrder` property (JavaFX 9+). For more information, see all the answers to [Z-Order in JavaFX](https://stackoverflow.com/questions/2988196/z-order-in-javafx). – Slaw Jan 30 '21 at 19:31

0 Answers0