-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7337d44
commit 47d9c99
Showing
88 changed files
with
5,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ProjectFinal; | ||
|
||
import javafx.animation.Animation; | ||
import javafx.animation.KeyFrame; | ||
import javafx.animation.Timeline; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
import javafx.util.Duration; | ||
|
||
import java.io.InputStream; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class ConeHeadZombie { | ||
|
||
public static int coneHeadZombieHealth = 30; | ||
|
||
String zombieGif = "myPicture/gif/ZombieGif.gif"; | ||
|
||
private int zombieImageChang (ImageView myImageView, int yZombieBlock, int currentZombie, int result) { | ||
if (GameData.zombieHealth[yZombieBlock].get (currentZombie) <= 10 && result == 1) { | ||
result = 0; | ||
InputStream input = getClass().getResourceAsStream(zombieGif); | ||
Image image = new Image(input); | ||
myImageView.setImage (image); | ||
myImageView.setFitHeight (120); | ||
myImageView.setFitWidth (80); | ||
} | ||
return result; | ||
} | ||
|
||
private void zombieImageChanger (ImageView myImageView, int yZombieBlock, int currentZombie) { | ||
AtomicInteger result = new AtomicInteger(); | ||
result.set (1); | ||
Timeline myTimeline = new Timeline (new KeyFrame(Duration.millis(10), | ||
(event) -> result.set(zombieImageChang (myImageView, yZombieBlock, currentZombie, result.get())))); | ||
myTimeline.setCycleCount (Animation.INDEFINITE); | ||
myTimeline.play(); | ||
} | ||
|
||
public void playConeHeadZombie (ImageView myImageView, int yZombieBlock, int currentZombie) { | ||
zombieImageChanger (myImageView, yZombieBlock, currentZombie); | ||
} | ||
|
||
} |
Oops, something went wrong.