-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoin.java
More file actions
32 lines (29 loc) · 806 Bytes
/
Coin.java
File metadata and controls
32 lines (29 loc) · 806 Bytes
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 mayflower.*;
public class Coin extends AnimatedActor
{
private Animation spin;
public Coin()
{
String[] spinAnimation = new String[8];
for (int i=0;i<8;i++)
{
spinAnimation[i] = "img/coin/frame_" + i + "_delay-0.1s.png";
}
spin = new Animation(8, spinAnimation);
setAnimation(spin);
}
public void act ()
{
super.act();
setLocation(getX(), getY()-4);
if (isTouching(Fish.class))
{
Object a = getOneIntersectingObject(Fish.class);
Fish f = (Fish) a;
World w = getWorld();
f.increaseScore(1);
Mayflower.playSound("sfx/coin_collect.wav");
setLocation(getX()+1000, getY()-1000);
}
}
}