Abfragen ob Taste gedrückt gehalten wird [Flash 8]
| Beiträge: 24 Registriert: Dec 2011
| 02.12.2012, 13:18
Hallo Liebes Forum,
Ich bin dabei ein kleines Spiel zu erstellen. Nun weiß ich nicht wie ich abfragen kann ob die z.b. Pfeiltaste Rechts gedrückt GEHALTEN wird. kann mir da jemand helfen??
Code:
ActionScript: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 | onClipEvent (load) {
var ground1:MovieClip = _root.ground1;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 12;
var maxJump:Number = -12;
var touchingGround1:Boolean = false;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground1.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}
if (ground1.hitTest(_x, _y+5, true)) {
touchingGround1 = true;
} else {
touchingGround1 = false;
}
if (Key.isDown(Key.RIGHT)) {
_root.char1.gotoAndPlay(1)
_x += speed;
}
if (Key.isDown(Key.LEFT)) {
_root.char1.gotoAndStop(2)
_x -= speed;
}
if (Key.isDown(Key.UP) && touchingGround1) {
grav = maxJump;
}
if (ground1.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (ground1.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground1.hitTest(_x, _y-(height), true)) {
grav = 3;
}
}
|
Liebe Grüße, Thormason | | | Beiträge: 1189 Wohnort: Boston MA Registriert: Feb 2006
| 03.12.2012, 19:54
|
|