@Test public void execute() throws Exception { Pane pane = mock(Pane.class); LinkedList<Node> paneChildren = new LinkedList<>(); when(pane.getChildren()).thenReturn(new ObservableListWrapper<>(paneChildren)); ImageView imageView = mock(ImageView.class); Explosion explosion = new Explosion(0.5, imageView); explosion.execute(pane); Assert.assertThat(paneChildren, hasSize(greaterThan(0))); }
@Override public void execute(Pane pane) { ImageView explosionImage = new ImageView(new Image(getClass().getResourceAsStream("/explosion.png"))); explosionImage.setScaleX(scale); explosionImage.setScaleY(scale); explosionImage.setX(imageView.getLayoutX() - imageView.getFitWidth() / 2); explosionImage.setY(imageView.getLayoutY() - imageView.getFitHeight() / 2); SpriteAnimation explosionAnimation = new SpriteAnimation(explosionImage, Duration.millis(1000), 40, 8, 0, 0, 256, 256); explosionAnimation.setCycleCount(1); explosionAnimation.play(); pane.getChildren().addAll(explosionImage); explosionAnimation.setOnFinished( event -> { pane.getChildren().remove(explosionImage); log.warn("Removed"); } ); }
Explosion extends UIUpdate { @Override public void execute(Pane pane) { ImageView explosionImage = new ImageView(new Image(getClass().getResourceAsStream("/explosion.png"))); explosionImage.setScaleX(scale); explosionImage.setScaleY(scale); explosionImage.setX(imageView.getLayoutX() - imageView.getFitWidth() / 2); explosionImage.setY(imageView.getLayoutY() - imageView.getFitHeight() / 2); SpriteAnimation explosionAnimation = new SpriteAnimation(explosionImage, Duration.millis(1000), 40, 8, 0, 0, 256, 256); explosionAnimation.setCycleCount(1); explosionAnimation.play(); pane.getChildren().addAll(explosionImage); explosionAnimation.setOnFinished( event -> { pane.getChildren().remove(explosionImage); log.warn("Removed"); } ); } }
Explosion extends UIUpdate { @Override public void execute(Pane pane) { ImageView explosionImage = new ImageView(new Image(getClass().getResourceAsStream("/explosion.png"))); explosionImage.setScaleX(scale); explosionImage.setScaleY(scale); explosionImage.setX(imageView.getLayoutX() - imageView.getFitWidth() / 2); explosionImage.setY(imageView.getLayoutY() - imageView.getFitHeight() / 2); SpriteAnimation explosionAnimation = new SpriteAnimation(explosionImage, Duration.millis(1000), 40, 8, 0, 0, 256, 256); explosionAnimation.setCycleCount(1); explosionAnimation.play(); pane.getChildren().addAll(explosionImage); explosionAnimation.setOnFinished( event -> { pane.getChildren().remove(explosionImage); log.warn("Removed"); } ); } Explosion(double scale, ImageView imageView); }
Explosion extends UIUpdate { @Override public void execute(Pane pane) { ImageView explosionImage = new ImageView(new Image(getClass().getResourceAsStream("/explosion.png"))); explosionImage.setScaleX(scale); explosionImage.setScaleY(scale); explosionImage.setX(imageView.getLayoutX() - imageView.getFitWidth() / 2); explosionImage.setY(imageView.getLayoutY() - imageView.getFitHeight() / 2); SpriteAnimation explosionAnimation = new SpriteAnimation(explosionImage, Duration.millis(1000), 40, 8, 0, 0, 256, 256); explosionAnimation.setCycleCount(1); explosionAnimation.play(); pane.getChildren().addAll(explosionImage); explosionAnimation.setOnFinished( event -> { pane.getChildren().remove(explosionImage); log.warn("Removed"); } ); } Explosion(double scale, ImageView imageView); @Override void execute(Pane pane); }
Explosion extends UIUpdate { @Override public void execute(Pane pane) { ImageView explosionImage = new ImageView(new Image(getClass().getResourceAsStream("/explosion.png"))); explosionImage.setScaleX(scale); explosionImage.setScaleY(scale); explosionImage.setX(imageView.getLayoutX() - imageView.getFitWidth() / 2); explosionImage.setY(imageView.getLayoutY() - imageView.getFitHeight() / 2); SpriteAnimation explosionAnimation = new SpriteAnimation(explosionImage, Duration.millis(1000), 40, 8, 0, 0, 256, 256); explosionAnimation.setCycleCount(1); explosionAnimation.play(); pane.getChildren().addAll(explosionImage); explosionAnimation.setOnFinished( event -> { pane.getChildren().remove(explosionImage); log.warn("Removed"); } ); } Explosion(double scale, ImageView imageView); @Override void execute(Pane pane);  }