
public function Engine() { //addChild(controls); addEventListener(Event.ENTER_FRAME,moveMap); } public function moveMap(event:Event) { if(controls.left){ trace(“LEFT!”); } else if(controls.right == true){ trace(“RIGHT!”); } }; };
public function Controls() { trace(“OK!?”); addEventListener(KeyboardEvent.KEY_DOWN,keyDownListener); addEventListener(KeyboardEvent.KEY_UP,keyUpListener); } //Inputs public function keyDownListener(evt:KeyboardEvent):void { switch (evt.keyCode) { case 13: enterReturn=true; break; case 87: trace(“UIP!”); up=true; break; case 83: down=true; break; case 65: left=true; break; case 68: right=true; break; case 69: showDisplay=true; break; } }; public function keyUpListener(evt:KeyboardEvent):void { switch (evt.keyCode) { //case 13: //enterReturn=false; //break; case 87: up=false; break; case 83: down=false; break; case 65: left=false; break; case 68: right=false; break; case 69: showDisplay=false; break; }; }; };
is it the addEventListener in the controls class? do i need to add it somewhere specific? How does the engine class know if the keys have been pressed in the controls class?
I hope this makes sense, I have tried everything I can think of and cant figure it out. I hope my newbie question makes someone laugh
Thank you so much for looking at my problem:confused:
If you would like to make a comment, please fill out the form below.
Recent Comments