-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet2.as
66 lines (66 loc) · 1.6 KB
/
Bullet2.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
class Bullet2 extends MovieClip {
var speed:Number;
var direction:Number;
var exists:Number; //从出现时的时间
var type:Number;
//种类
function Bullet2() {
exists = 0;
}
function initial() {
_rotation = direction;
onEnterFrame = function () {
exists++;
if (this._x<-80 || this._y<-80 || this._x>Stage.width+80 || this._y>Stage.height+80) {
removeMovieClip(this);
}
if (!_root.boss.invincible && hitTest(_root.boss._x, _root.boss._y, true)) {
_root.boss.life --;
_root.charge += 1;
removeMovieClip(this);
//trace("MISS!");
}
moveMode(type);
};
}
function normalMove():Void {
//直线运动
var cos = Math.cos(direction/180*Math.PI);
var sin = Math.sin(direction/180*Math.PI);
_rotation = direction;
_x += speed*cos;
_y += speed*sin;
}
function gravityMove(para:Number):Void {
//重力运动(抛物线)para越大重力影响越小,para为负时为反重力
var cos = Math.cos(direction/180*Math.PI);
var sin = Math.sin(direction/180*Math.PI);
_rotation = direction;
_x += speed*cos;
_y += speed*sin+exists/para;
}
function directChange(para:Number):Void{
//更改角度:1为水平翻转,2为垂直翻转,3为旋转180
switch(para){
case 1:
direction = -direction;
break;
case 2:
direction = 180-direction;
break;
case 3:
direction = direction-180;
break;
}
}
private function getXY():Array{
return [_x,_y];
}
function moveMode(bulletType:Number):Void {
switch (bulletType) {
case 0 :
normalMove();
break;
}
}
}