changement des
This commit is contained in:
parent
5d97ac65b8
commit
5ccf1a731b
@ -12,7 +12,7 @@ public class Main extends Application {
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
System.out.println("Lancement de l'application");
|
||||
|
||||
Pane root = FXMLLoader.load(getClass().getResource("ressources/Menu.fxml")); // "ressources/Jouer_tour(1)lancer_des.fxml"
|
||||
Pane root = FXMLLoader.load(getClass().getResource("ressources/des.fxml")); // "ressources/Jouer_tour(1)lancer_des.fxml"
|
||||
|
||||
primaryStage.setTitle("Shadow Hunters");
|
||||
primaryStage.setScene(new Scene(root));
|
||||
|
47
src/ihm/SpriteAnimation.java
Normal file
47
src/ihm/SpriteAnimation.java
Normal file
@ -0,0 +1,47 @@
|
||||
package ihm;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.Transition;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class SpriteAnimation extends Transition {
|
||||
|
||||
private final ImageView imageView;
|
||||
private final int count;
|
||||
private final int columns;
|
||||
private final int offsetX;
|
||||
private final int offsetY;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
private int lastIndex;
|
||||
|
||||
public SpriteAnimation(
|
||||
ImageView imageView,
|
||||
Duration duration,
|
||||
int count, int columns,
|
||||
int offsetX, int offsetY,
|
||||
int width, int height) {
|
||||
this.imageView = imageView;
|
||||
this.count = count;
|
||||
this.columns = columns;
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
setCycleDuration(duration);
|
||||
setInterpolator(Interpolator.LINEAR);
|
||||
}
|
||||
|
||||
protected void interpolate(double k) {
|
||||
final int index = Math.min((int) Math.floor(k * count), count - 1);
|
||||
if (index != lastIndex) {
|
||||
final int x = (index % columns) * width + offsetX;
|
||||
final int y = (index / columns) * height + offsetY;
|
||||
imageView.setViewport(new Rectangle2D(x, y, width, height));
|
||||
lastIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,8 +19,6 @@ public class JouerSonTour1Controller implements Initializable{
|
||||
private Joueur joueur;
|
||||
|
||||
@FXML private Pane rootPane;
|
||||
@FXML private Label d6;
|
||||
@FXML private Label d4;
|
||||
@FXML private Label nomJoueur;
|
||||
|
||||
@Override
|
||||
@ -30,13 +28,7 @@ public class JouerSonTour1Controller implements Initializable{
|
||||
|
||||
@FXML
|
||||
public void lancerDes(MouseEvent mouseEvent) throws IOException, InterruptedException{
|
||||
//lancer d6
|
||||
int d6 = new Random().nextInt(6) + 1;
|
||||
this.d6.setText(Integer.toString(d6));
|
||||
|
||||
//lancer d4
|
||||
int d4 = new Random().nextInt(4) + 1;
|
||||
this.d6.setText(Integer.toString(d4));
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
|
@ -20,14 +20,6 @@
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font></Button>
|
||||
<Label fx:id="d6" layoutX="199.0" layoutY="190.0" styleClass="des" text="6">
|
||||
<font>
|
||||
<Font size="64.0" />
|
||||
</font></Label>
|
||||
<Label fx:id="d4" layoutX="433.0" layoutY="211.0" styleClass="des" text="4">
|
||||
<font>
|
||||
<Font size="64.0" />
|
||||
</font></Label>
|
||||
<Label fx:id="nomJoueur" layoutX="405.0" layoutY="29.0" text="joueur 1">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
|
11
src/ihm/ressources/img/des.fxml
Normal file
11
src/ihm/ressources/img/des.fxml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
|
||||
|
||||
<ImageView fitHeight="33.0" fitWidth="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<image>
|
||||
<Image url="@dice.sprite.png" />
|
||||
</image>
|
||||
</ImageView>
|
Loading…
x
Reference in New Issue
Block a user