Fixed the issue where the ship shot with no guns

This commit is contained in:
KahootChampion
2019-03-24 21:25:57 -06:00
parent 2fb5d2fb1a
commit 799704ad5c

View File

@@ -1,4 +1,3 @@
import javafx.animation.*; import javafx.animation.*;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@@ -322,11 +321,17 @@ public class AnimationTesting extends Player {
if(getGuns()>0) { if(getGuns()>0) {
shotsFired.setCycleCount(getGuns()); shotsFired.setCycleCount(getGuns());
} }
else{
shotsFired.setCycleCount(0);
shotsFired.stop();
cannon.setVisible(false);
}
shotsFired.setNode(cannon); shotsFired.setNode(cannon);
shotsFired.play(); shotsFired.play();
} }
public void shipsRetaliate(){ public void shipsRetaliate(){
cannon.setVisible(true);
enemyShots.setFromX(270); enemyShots.setFromX(270);
enemyShots.setFromY(0); enemyShots.setFromY(0);
enemyShots.setToX(-30); enemyShots.setToX(-30);
@@ -633,10 +638,6 @@ public class AnimationTesting extends Player {
} }
}); });
} }
} }
@@ -644,100 +645,3 @@ public class AnimationTesting extends Player {
/*
for (int i = 0; i < 5; i++) {
cannon.setLayoutX(beginningX);
cannon.setLayoutY(beginningY);
@Override
public void handle(Event event) {
for (int i = 0; i < 5; i++) {
if (i == 2) {
shotsFired.setFromX(0);
shotsFired.setFromY(0);
shotsFired.setToX(endX + 60);
shotsFired.setToY(endY + 70);
shotsFired.setFromX(0);
shotsFired.setFromY(0);
shotsFired.setToX(endX);
shotsFired.setToY(endY);
shotsFired.setNode(cannon);
shotsFired.play();
} else {
shotsFired.setFromX(0);
shotsFired.setFromY(0);
shotsFired.setToX(endX );
shotsFired.setToY(endY );
shotsFired.setFromX(0);
shotsFired.setFromY(0);
shotsFired.setToX(endX);
shotsFired.setToY(endY);
shotsFired.setNode(cannon);
shotsFired.get
shotsFired.play();
}
}
}
});
shotsFired.setDuration(Duration.seconds(3));
shotsFired.setCycleCount(5);
shotsFired.play();
shotsFired.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
shotsFired.stop();
}
});
}
/*
destroyLittyShipsOrEscape(primaryStage);
} catch (Exception e) {
}
if (counter >= 1) {
title.setVisible(false);
}
}
}
});
Scene scene = new Scene(root, 600, 480);
root.getStylesheets().add("styleguide.css");
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.show();
}
*/