-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetherPortal.java
32 lines (28 loc) · 1.01 KB
/
NetherPortal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import kuusisto.tinysound.Music;
import kuusisto.tinysound.TinySound;
import mayflower.*;
public class NetherPortal extends Actor {
private final Music mu;
public NetherPortal() {
MayflowerImage m = new MayflowerImage("assets/Object/netherportal2.png");
m.scale(128, 128);
setImage(m);
TinySound.init();
mu = TinySound.loadMusic("assets/music/subwooferlullaby.wav");
mu.play(true);
}
public void act() {
// move to LevelTwo if cat hits nether portal, with same health and score as the one from world1
if (isTouching(Cat.class)) {
Cat c = getOneIntersectingObject(Cat.class);
int currentHealth, currentScore;
currentHealth = c.getHealth();
currentScore = c.getScore();
mu.stop();
World newWorld = new LevelTwo(currentScore, currentHealth);
Mayflower.setWorld(newWorld);
}
}
public void pause() { mu.pause(); }
public void resume() { mu.resume(); }
}