-
Notifications
You must be signed in to change notification settings - Fork 0
/
shield.as
44 lines (37 loc) · 879 Bytes
/
shield.as
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
// shield
// Supernaut Player
package {
import net.flashpunk.*;
import net.flashpunk.graphics.*;
public class shield extends Entity {
[Embed(source = 'assets/shield.png')]
private const shieldimg:Class;
public var sprShield:Spritemap = new Spritemap(shieldimg, 128,100);
public var count:int = 0;
public function shield():void {
sprShield.add("play", [0,1,2,3],30,true);
graphic = sprShield;
x = 0;
y = 0;
width = 128;
height = 100;
visible = false;
}
override public function update():void {
if (Player.shield) {
sprShield.play("play");
x = (Player.oldX+Player.width/2-10); //(Player.oldX-10);
y = (Player.oldY+Player.height/2-20); //(Player.oldY-20);
visible = true;
if (count < 5) {
count++
}
if (count >=5) {
Player.shield = false;
count = 0
visible = false;
}
}
}
}
}