diff --git a/src/ihm/Main.java b/src/ihm/Main.java index d17849e..eea36f6 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -16,7 +16,7 @@ public class Main extends Application { public void start(Stage primaryStage) throws Exception { System.out.println("Lancement de l'application"); - final URL fxmlURL = getClass().getResource("ressources/Menu.fxml"); // "ressources/Jouer_tour(1)lancer_des.fxml" + final URL fxmlURL = getClass().getResource("ressources/Jouer_tour(1)lancer_des.fxml"); // "ressources/Jouer_tour(1)lancer_des.fxml" final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRANCE); final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle); Pane root = fxmlLoader.load(); diff --git a/src/ihm/controller/JouerSonTour1Controller.java b/src/ihm/controller/JouerSonTour1Controller.java index f641fbd..dac0c00 100644 --- a/src/ihm/controller/JouerSonTour1Controller.java +++ b/src/ihm/controller/JouerSonTour1Controller.java @@ -6,13 +6,22 @@ import java.util.Random; import java.util.ResourceBundle; import carte.CarteLieu; +import ihm.SpriteAnimation; +import javafx.animation.Animation; +import javafx.event.Event; +import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; +import javafx.scene.Group; import javafx.scene.control.Label; +import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; +import javafx.util.Duration; import main.Joueur; public class JouerSonTour1Controller implements Initializable{ @@ -20,10 +29,53 @@ public class JouerSonTour1Controller implements Initializable{ @FXML private Pane rootPane; @FXML private Label nomJoueur; + @FXML private AnchorPane d6; + @FXML private AnchorPane d4; @Override public void initialize(URL arg0, ResourceBundle arg1) { //nomJoueur.setText(joueur.getNom()); + + int OFFSET_X = 0; + int OFFSET_Y = 0; + int WIDTH = 200; + int HEIGHT = 200; + int COUNT = 6; + int COLUMNS = 6; + + //anchorPane1.getChildren().setAll(imageView); + + + ImageView imageView; + try { + imageView = FXMLLoader.load(getClass().getResource("../ressources/img/des.fxml")); + imageView.setViewport(new Rectangle2D(OFFSET_X, OFFSET_Y, WIDTH, HEIGHT)); + + imageView.fitWidthProperty().bind(d6.widthProperty()); + final SpriteAnimation animation = new SpriteAnimation( + imageView, + Duration.millis(250), + COUNT, COLUMNS, + OFFSET_X, OFFSET_Y, + 557, 557 + ); + animation.setCycleCount(Animation.INDEFINITE); + animation.play(); + d6.getChildren().addAll(new Group(imageView)); + d6.setOnMousePressed(new EventHandler( + + ) { + + @Override + public void handle(Event arg0) { + animation.stop(); + + } + }); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } @FXML diff --git a/src/ihm/ressources/Jouer_tour(1)lancer_des.fxml b/src/ihm/ressources/Jouer_tour(1)lancer_des.fxml index dc83f10..1f12ad6 100644 --- a/src/ihm/ressources/Jouer_tour(1)lancer_des.fxml +++ b/src/ihm/ressources/Jouer_tour(1)lancer_des.fxml @@ -2,9 +2,8 @@ + - - @@ -14,8 +13,6 @@ - -