v0.8.0: refactored KeyAction into int constants so it can be expanded

This commit is contained in:
Evan Debenham
2019-12-13 23:22:44 -05:00
parent cb76fb8188
commit f269d68a27
15 changed files with 176 additions and 114 deletions
@@ -30,7 +30,7 @@ import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Blending;
import com.watabou.glwrap.Vertexbuffer;
import com.watabou.input.InputHandler;
import com.watabou.input.KeyEvent;
import com.watabou.input.KeyAction;
import com.watabou.noosa.audio.Music;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Callback;
@@ -100,6 +100,7 @@ public class Game implements ApplicationListener {
Blending.useDefault();
inputHandler = new InputHandler( Gdx.input );
KeyAction.initialize();
//refreshes texture and vertex data stored on the gpu
TextureCache.reload();
@@ -21,6 +21,7 @@
package com.watabou.noosa;
import com.watabou.input.KeyAction;
import com.watabou.input.KeyBindings;
import com.watabou.input.KeyEvent;
import com.watabou.utils.Signal;
@@ -35,10 +36,10 @@ public class Scene extends Group {
public boolean onSignal( KeyEvent event ) {
if (Game.instance != null && event.pressed) {
switch (KeyBindings.getBinding( event )) {
case BACK:
case KeyAction.BACK:
onBackPressed();
break;
case MENU:
case KeyAction.MENU:
onMenuPressed();
break;
}
@@ -66,7 +66,7 @@ public class Button extends Component {
KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
@Override
public boolean onSignal ( KeyEvent event ) {
if ( active && !event.pressed && KeyBindings.getBinding( event ) != null
if ( active && !event.pressed
&& KeyBindings.getBinding( event ) == keyAction()){
onClick();
return true;
@@ -78,8 +78,8 @@ public class Button extends Component {
private Signal.Listener<KeyEvent> keyListener;
public KeyAction keyAction(){
return null;
public int keyAction(){
return KeyAction.NONE;
}
@Override