-
Notifications
You must be signed in to change notification settings - Fork 0
/
Power.java
38 lines (30 loc) · 844 Bytes
/
Power.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
33
34
35
36
37
38
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public abstract class Power extends Actor
{
private GreenfootImage powerB;
private GreenfootImage powerR;
private int changeImage;
private int power;
protected abstract void touchPower(Player player);
public Power(int p)
{
power = p;
powerB = new GreenfootImage("power" + power + "b" + ".png");
powerR = new GreenfootImage("power" + power + "r" + ".png");
}
public void act()
{
setImage();
}
public void setImage()
{
if(changeImage++ == 10)
{
if(getImage() == powerB)
setImage(powerR);
else
setImage(powerB);
changeImage = 0;
}
}
}