added Bell animation - makes the whole thing a bit laggy but is still wonderful!
This commit is contained in:
parent
8ecfd8e5e1
commit
cc0fd64c71
@ -0,0 +1,29 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.Transition;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class BellAnimation extends Transition {
|
||||
ImageView imageView;
|
||||
Image[] bells;
|
||||
int index;
|
||||
|
||||
public BellAnimation(ImageView imageView, Image[] bells) {
|
||||
setCycleCount(17);
|
||||
index = 0;
|
||||
this.imageView = imageView;
|
||||
this.bells = bells;
|
||||
setCycleDuration(new Duration(59));
|
||||
setInterpolator(Interpolator.DISCRETE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void interpolate(double frac) {
|
||||
imageView.setImage(bells[index]);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -36,8 +37,24 @@ public class GameController implements Initializable {
|
||||
|
||||
private static GameStateModel gameStateModel;
|
||||
|
||||
Image[] bells = new Image[17];
|
||||
|
||||
public GameController() {
|
||||
super();
|
||||
try {
|
||||
for (int i = 1; i <= 17; i++) {
|
||||
String url;
|
||||
if (i < 10) {
|
||||
url =
|
||||
"ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/Day/Bell/Image000" + i + ".png";
|
||||
} else {
|
||||
url = "ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/Day/Bell/Image00" + i + ".png";
|
||||
}
|
||||
bells[i-1] = new Image(url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(Seraina, Sebi): Same issue as ChatController? do with setters?
|
||||
@ -540,7 +557,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[0]) {
|
||||
noiseImage0.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage5, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
@ -560,7 +578,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[1]) {
|
||||
noiseImage1.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage4, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
@ -579,7 +598,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[2]) {
|
||||
noiseImage2.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage3, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
@ -599,7 +619,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[3]) {
|
||||
noiseImage3.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage2, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
@ -618,7 +639,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[4]) {
|
||||
noiseImage4.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage1, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
@ -637,7 +659,8 @@ public class GameController implements Initializable {
|
||||
public void run() {
|
||||
try {
|
||||
if(!gameStateModel.getKickedOff()[5]) {
|
||||
noiseImage5.setImage(loadBellImage());
|
||||
Animation bell = new BellAnimation(noiseImage0, bells);
|
||||
bell.play();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug(e.getMessage());
|
||||
|
||||
@ -41,18 +41,14 @@
|
||||
<Image url="@Day/Room6.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView fx:id="noiseImage0" fitHeight="843.75" fitWidth="1500.0" preserveRatio="true" />
|
||||
<ImageView fx:id="noiseImage1" fitHeight="843.75" fitWidth="1500.0" layoutX="-117.0" layoutY="-25.02" preserveRatio="true" />
|
||||
<ImageView fx:id="noiseImage2" fitHeight="843.75" fitWidth="1500.0" layoutX="-234.0" layoutY="-50.04" preserveRatio="true" />
|
||||
<ImageView fx:id="noiseImage3" fitHeight="843.75" fitWidth="1500.0" layoutX="-351.0" layoutY="-75.06" preserveRatio="true" />
|
||||
<ImageView fx:id="noiseImage4" fitHeight="843.75" fitWidth="1500.0" layoutX="-468.0" layoutY="-100.08" preserveRatio="true" />
|
||||
<ImageView fx:id="noiseImage5" fitHeight="843.75" fitWidth="1500.0" layoutX="-585.0" layoutY="-125.1" preserveRatio="true" />
|
||||
<Group fx:id="roomButtonGroupDay" layoutX="288.0" layoutY="220.0">
|
||||
<children>
|
||||
<HBox fx:id="notificationHBox" layoutX="20.0" layoutY="-55.0" pickOnBounds="false" rotate="12.4">
|
||||
<children>
|
||||
<ImageView fx:id="noiseImage0" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
<ImageView fx:id="noiseImage1" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
<ImageView fx:id="noiseImage2" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
<ImageView fx:id="noiseImage3" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
<ImageView fx:id="noiseImage4" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
<ImageView fx:id="noiseImage5" fitHeight="150.0" fitWidth="125.0" preserveRatio="true" rotate="-12.4" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="roomLables" alignment="CENTER" layoutY="82.0" prefHeight="62.0" prefWidth="747.0" rotate="12.2">
|
||||
<children>
|
||||
<TextFlow fx:id="lableRoom0" prefHeight="200.0" prefWidth="200.0" textAlignment="CENTER" />
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.shape.Line?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
|
||||
<AnchorPane fx:id="backGroundAnchorPane" pickOnBounds="false" stylesheets="@loungStyle.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeSceneViewController">
|
||||
@ -46,7 +45,6 @@
|
||||
<TextFlow fx:id="highScore" layoutX="62.0" layoutY="232.0" pickOnBounds="false" prefHeight="167.0" prefWidth="181.0" AnchorPane.bottomAnchor="1.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="232.0" />
|
||||
<Label layoutX="67.0" layoutY="6.0" pickOnBounds="false" text="Players:" />
|
||||
<TextFlow fx:id="lobbyPrint" layoutX="5.0" layoutY="23.0" pickOnBounds="false" prefHeight="178.0" prefWidth="171.0" />
|
||||
<Line endX="72.5" layoutX="91.0" layoutY="201.0" startX="-79.5" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</left>
|
||||
|
||||
Reference in New Issue
Block a user