added keyboard input
This commit is contained in:
parent
b4f9559d19
commit
bbd08f0065
@ -1,6 +1,9 @@
|
|||||||
|
import openfl.events.KeyboardEvent;
|
||||||
import openfl.display.Sprite;
|
import openfl.display.Sprite;
|
||||||
import openfl.display.Stage;
|
import openfl.display.Stage;
|
||||||
import openfl.events.Event;
|
import openfl.events.Event;
|
||||||
|
import game.Game;
|
||||||
|
|
||||||
class Main extends Sprite {
|
class Main extends Sprite {
|
||||||
public function new () {
|
public function new () {
|
||||||
super ();
|
super ();
|
||||||
@ -8,6 +11,8 @@ class Main extends Sprite {
|
|||||||
var game:Game = new Game(stage);
|
var game:Game = new Game(stage);
|
||||||
game.onInit();
|
game.onInit();
|
||||||
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
||||||
|
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);
|
||||||
|
stage.addEventListener(KeyboardEvent.KEY_UP,keyIsUp);
|
||||||
stage.addEventListener(Event.RESIZE,onResize);
|
stage.addEventListener(Event.RESIZE,onResize);
|
||||||
stage.application.window.resize(1920, 1080);
|
stage.application.window.resize(1920, 1080);
|
||||||
stage.application.window.title = "Kanker";
|
stage.application.window.title = "Kanker";
|
||||||
@ -17,5 +22,12 @@ class Main extends Sprite {
|
|||||||
//Here we can do shit with window scaling
|
//Here we can do shit with window scaling
|
||||||
//stage.stageWidth;
|
//stage.stageWidth;
|
||||||
//stage.stageHeight;
|
//stage.stageHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function keyIsDown(e:KeyboardEvent){
|
||||||
|
Game.keys[e.keyCode] = true;
|
||||||
|
}
|
||||||
|
private function keyIsUp(e:KeyboardEvent){
|
||||||
|
Game.keys[e.keyCode] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user