-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBow.as
More file actions
45 lines (42 loc) · 1.18 KB
/
Bow.as
File metadata and controls
45 lines (42 loc) · 1.18 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
package {
import flash.display.MovieClip;
import flash.events.*;
public class Bow extends MovieClip{
private var _root:*;
public var hasUse:Boolean = true;
private var reloadTime:int = 24;
private var damage:int = 5;
private var speed:int = 20;
private var knockBack:int = 10;
private var curSlot:int;
private var ran:Boolean;
public function Bow(passSlot:int) {
curSlot = passSlot;
addEventListener(Event.ADDED,beginClass);
addEventListener(Event.ENTER_FRAME, eFrame);
}
private function beginClass(e:Event):void {
if (!ran){
ran = true;
_root = MovieClip(root);
}
}
private function eFrame(e:Event):void{
this.x = _root.player.x;
this.y = _root.player.y;
this.rotation = _root.player.rotation;
}
public function useItem(){
if (_root.isLongRangeAttackReady){
_root.longRangeLoadCount = reloadTime;
_root.isLongRangeAttackReady = false;
this.gotoAndPlay("bowShot");
var newArrow:Arrow = new Arrow(damage, speed, knockBack, true);
newArrow.x = this.x;
newArrow.y = this.y;
newArrow.rotation = this.rotation;
_root.ObjectHolder.addChild(newArrow);
}
}
}
}