-
Notifications
You must be signed in to change notification settings - Fork 1
/
Shoot.as
118 lines (82 loc) · 2.73 KB
/
Shoot.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.display.Shape;
import flash.display.Sprite;
import flashx.textLayout.events.UpdateCompleteEvent;
import flash.ui.Keyboard;
public class Shoot extends MovieClip {
public function Shoot() {
arr1= new Arrow();
sh1= new Shooter(false);
up1 = new Update();
this.createbutton(); //creates button and its all related task
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//stage.addEventListener(MouseEvent.CLICK,addlistener);
}
public function createbutton():void{
bp1=new Butplay();
stage.addChild(bp1);
bp1.x=this.getstgwidth()/2 -bp1.width/2;
bp1.y =this.getstgheight()/2-bp1.height/2;
bp1.addEventListener(MouseEvent.CLICK,buttonclicked);
}
// perfroms the movement of the arrow and checks for the collision
public function perform(e:Event=null):void{
trace("perform");
}
// moves the shooter up and down
public function update(e:KeyboardEvent):void{
trace("key");
if(e.keyCode==(Keyboard.DOWN))
up1.upshoo(sh1,arr1);
}
//once button clicked game starts, button is removed.
public function buttonclicked(e:MouseEvent):void{
trace("button clicked");
//stage.addEventListener(Event.ENTER_FRAME,perform);
stage.addEventListener(KeyboardEvent.KEY_DOWN,update);
//stage.removeChild(bp1);
stage.addChild(sh1);
sh1.y=this.getstgheight()/2-sh1.height/2;
stage.addChild(arr1);
arr1.y=this.getstgheight()/2-arr1.height/2;
arr1.x=sh1.x+sh1.width;
sh1.y=this.getstgheight()/2;
bp1.visible=false;
bp1.removeEventListener(MouseEvent.CLICK,update);
}
public function getstgwidth():int{
return stage.stageWidth;
}
public function getstgheight():int{
return stage.stageHeight;
}
/*
public function getTextButton(label:String):Sprite{
var txt:TextField = new TextField();
txt.defaultTextFormat = new TextFormat('Verdana',10,0x000000);
txt.text = label;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.background = txt.border = true;
txt.selectable = false;
var btn:Sprite = new Sprite();
btn.mouseChildren = false;
btn.addChild(txt);
btn.buttonMode = true;
return btn;
}*/
var arr1:Arrow; //moving arrow
var sh1:Shooter; // moving shooter
var bp1:Butplay; // play button
var up1:Update;
}
}