-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJumpEngine.as
More file actions
89 lines (81 loc) · 1.35 KB
/
JumpEngine.as
File metadata and controls
89 lines (81 loc) · 1.35 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
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
import flash.events.KeyboardEvent;
import flash.events.Event;
//이 위는 정의 과정에서 자동으로 생성됨
var Li = false;
var Ri = false;
var Si = false;
//방향키, 스페이스 변수
var St = true;
//중력 관련 변수
var G1 = 1;
var G2 = 0;
//G1:중력 변수 G2:중력 가속도 변수
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydown);
function keydown(e:KeyboardEvent)
{
if(e.keyCode == 37)
{
Li = true;
Mover.gotoAndStop(2);
}
if(e.keyCode == 39)
{
Ri = true;
Mover.gotoAndStop(1);
}
if(e.keyCode == 32)
{
Si = true;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP,keyup);
function keyup(e:KeyboardEvent)
{
if(e.keyCode == 37)
{
Li = false;
}
if(e.keyCode == 39)
{
Ri = false;
}
/*if(e.keyCode == 32)
{
Si = false;
}*/
}
stage.addEventListener(Event.ENTER_FRAME,moveandgrav);
function moveandgrav(e:Event)
{
if(Li == true)
{
block.x += 5;
}
if(Ri == true)
{
block.x -= 5;
}
if(Si == true)
{
Mover.y -= 14;
}
if(St == true)
{
G2 += G1;
Mover.y += G2;
}
}
stage.addEventListener(Event.ENTER_FRAME,blcoka);
function blcoka(e:Event)
{
if(block.hitTestPoint(Mover.x,Mover.y,true) == true)
{
G1 -= 1.5;
G2 = 0
Si = false;
}
if(block.hitTestPoint(Mover.x,Mover.y,true) == false)
{
G1 = 1;
}
}