-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShadowNinja.java
More file actions
45 lines (36 loc) · 1.06 KB
/
ShadowNinja.java
File metadata and controls
45 lines (36 loc) · 1.06 KB
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
39
40
41
42
43
44
45
import greenfoot.*; // import every greefoot function, object and more
public class ShadowNinja extends NinjaEnemys
{
private int invisibleTimer = 0;
private boolean isInvisible = false; // if ninja is visible or not
public ShadowNinja()
{
super(3); // set speed
GreenfootImage image = new GreenfootImage("./images/shadow_ninja.png");
this.setImage(image);
}
public void moving()
{
this.move(-this.speed);
}
public void skills() {
this.invisible();
}
private void invisible() {
this.invisibleTimer++;
// set the ninja invisible after a ceratin time
if (this.invisibleTimer > 50) {
this.isInvisible = !isInvisible;
if (this.isInvisible) {
this.getImage().setTransparency(0);
} else {
this.getImage().setTransparency(255);
}
this.invisibleTimer = 0;
}
}
@Override
public int getDamage() {
return 2;
}
}