Hi,
I have simple keys mechanic with Keys class.
"Keys" class:
package game
{
public class Keys
{
public function Keys()
{
}
public var RIGHT:Boolean;
public var LEFT:Boolean;
public var DOWN:Boolean;
public var UP:Boolean;
}
}
Main Game mechanic:
Starling.current.nativeStage.addEventListener(KeyboardEvent.KEY_DOWN,keyDown);
Starling.current.nativeStage.addEventListener(KeyboardEvent.KEY_UP,keyUp);
private function keyUp(e:KeyboardEvent):void {
if (e.keyCode == Keyboard.W || e.keyCode == Keyboard.UP) keys.UP = false;
if (e.keyCode == Keyboard.S || e.keyCode == Keyboard.DOWN) keys.DOWN = false
if (e.keyCode == Keyboard.D || e.keyCode == Keyboard.RIGHT) keys.RIGHT = false;
if (e.keyCode == Keyboard.A || e.keyCode == Keyboard.LEFT) keys.LEFT = false;
}
private function keyDown(e:KeyboardEvent):void {
if (e.keyCode == Keyboard.SPACE) {
addChildAt(bulletManager.returnBullet,numChildren - 1);
}
if (e.keyCode == Keyboard.W || e.keyCode == Keyboard.UP) keys.UP = true;
if (e.keyCode == Keyboard.S || e.keyCode == Keyboard.DOWN) keys.DOWN = true;
if (e.keyCode == Keyboard.D || e.keyCode == Keyboard.RIGHT) keys.RIGHT = true;
if (e.keyCode == Keyboard.A || e.keyCode == Keyboard.LEFT) keys.LEFT = true;
}
There is a difference in WSAD/arrows behaviour. WSAD works ok. But when I press two arrows at once then space key is not detected. Except when it is specific combination right+up. So it works like this:
W+D+SPACE = ok (pressing SPACE is detected)
W+A+SPACE = ok (pressing SPACE is detected)
S+D+SPACE = ok (pressing SPACE is detected)
S+A+SPACE = ok (pressing SPACE is detected)
RIGHT+UP+SPACE = ok (pressing SPACE is detected)
RIGHT+DOWN+SPACE = pressing space does nothing
LEFT+UP+SPACE = pressing space does nothing
LEFT+DOWN+SPACE = pressing space does nothing
It doesn't make any sense, the behaviour of WSAD/arrows should be the same. Has anyone had this problem before?