com.watabou.input.Keys Java Examples

The following examples show how to use com.watabou.input.Keys. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	Keys.event.add( keyListener = new Signal.Listener<Keys.Key>() {
		@Override
		public void onSignal( Keys.Key key ) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
				case Keys.BACK:
					onBackPressed();
					break;
				case Keys.MENU:
					onMenuPressed();
					break;
				}
			}
		}
	} );
}
 
Example #2
Source File: Scene.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	Keys.event.add( keyListener = new Signal.Listener<Keys.Key>() {
		@Override
		public void onSignal( Keys.Key key ) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
				case Keys.BACK:
					onBackPressed();
					break;
				case Keys.MENU:
					onMenuPressed();
					break;
				}
			}
		}
	} );
}
 
Example #3
Source File: Game.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@SneakyThrows
private void step() {

    if (requestedReset) {
        requestedReset = false;
        switchScene(sceneClass.newInstance());
        return;
   }

    Game.elapsed = Game.timeScale * step * 0.001f;

    synchronized (motionEvents) {
        Touchscreen.processTouchEvents(motionEvents);
        motionEvents.clear();
    }
    synchronized (keysEvents) {
        Keys.processTouchEvents(keysEvents);
        keysEvents.clear();
    }

    scene.update();
    Camera.updateAll();
}
 
Example #4
Source File: Scene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void create() {
	Keys.event.add( keyListener = key -> {
		if (Game.instance() != null && key.pressed) {
			switch (key.code) {
			case Keys.BACK:
				onBackPressed();
				break;
			case Keys.MENU:
				onMenuPressed();
				break;
			}
		}
	});
}
 
Example #5
Source File: Game.java    From PD-classes with GNU General Public License v3.0 5 votes vote down vote up
protected void update() {
	Game.elapsed = Game.timeScale * step * 0.001f;
	
	synchronized (motionEvents) {
		Touchscreen.processTouchEvents( motionEvents );
		motionEvents.clear();
	}
	synchronized (keysEvents) {
		Keys.processTouchEvents( keysEvents );
		keysEvents.clear();
	}
	
	scene.update();		
	Camera.updateAll();
}
 
Example #6
Source File: Game.java    From PD-classes with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyUp( int keyCode, KeyEvent event ) {
	
	if (keyCode == Keys.VOLUME_DOWN || 
		keyCode == Keys.VOLUME_UP) {
		
		return false;
	}
	
	synchronized (motionEvents) {
		keysEvents.add( event );
	}
	return true;
}
 
Example #7
Source File: Game.java    From PD-classes with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyDown( int keyCode, KeyEvent event ) {
	
	if (keyCode == Keys.VOLUME_DOWN || 
		keyCode == Keys.VOLUME_UP) {
		
		return false;
	}
	
	synchronized (motionEvents) {
		keysEvents.add( event );
	}
	return true;
}
 
Example #8
Source File: Window.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSignal( Key key ) {
	if (key.pressed) {
		switch (key.code) {
		case Keys.BACK:
			onBackPressed();			
			break;
		case Keys.MENU:
			onMenuPressed();			
			break;
		}
	}
	
	Keys.event.cancel();
}
 
Example #9
Source File: Window.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void destroy() {
	super.destroy();
	
	Camera.remove( camera );
	Keys.event.remove( this );
}
 
Example #10
Source File: Game.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {

    if (keyCode == Keys.VOLUME_DOWN || keyCode == Keys.VOLUME_UP) {
        return super.onKeyUp(keyCode, event);
    }

    synchronized (keysEvents) {
        keysEvents.add(event);
    }
    return true;
}
 
Example #11
Source File: Game.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == Keys.VOLUME_DOWN || keyCode == Keys.VOLUME_UP) {
        return super.onKeyUp(keyCode, event);
    }

    synchronized (keysEvents) {
        keysEvents.add(event);
    }
    return true;
}
 
Example #12
Source File: Window.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void destroy() {
	super.destroy();
	
	Camera.remove( camera );
	Keys.event.remove( this );
}
 
Example #13
Source File: Window.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSignal( Key key ) {
	if (key.pressed) {
		switch (key.code) {
		case Keys.BACK:
			onBackPressed();			
			break;
		case Keys.MENU:
			onMenuPressed();			
			break;
		}
	}
	
	Keys.event.cancel();
}
 
Example #14
Source File: Window.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void destroy() {
	super.destroy();
	
	Camera.remove( camera );
	Keys.event.remove( this );
}
 
Example #15
Source File: Window.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSignal( Key key ) {
	if (key.pressed) {
		switch (key.code) {
		case Keys.BACK:
			onBackPressed();
			break;
		case Keys.MENU:
			onMenuPressed();
			break;
		}
	}
	
	Keys.event.cancel();
}
 
Example #16
Source File: Window.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void destroy() {
	super.destroy();
	
	Camera.remove( camera );
	Keys.event.remove( this );
}
 
Example #17
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
protected void update() {
	Game.elapsed = Game.timeScale * step * 0.001f;
	
	synchronized (motionEvents) {
		Touchscreen.processTouchEvents( motionEvents );
		motionEvents.clear();
	}
	synchronized (keysEvents) {
		Keys.processTouchEvents( keysEvents );
		keysEvents.clear();
	}
	
	scene.update();		
	Camera.updateAll();
}
 
Example #18
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyUp( int keyCode, KeyEvent event ) {
	
	if (keyCode == Keys.VOLUME_DOWN || 
		keyCode == Keys.VOLUME_UP) {
		
		return false;
	}
	
	synchronized (motionEvents) {
		keysEvents.add( event );
	}
	return true;
}
 
Example #19
Source File: Game.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onKeyDown( int keyCode, KeyEvent event ) {
	
	if (keyCode == Keys.VOLUME_DOWN || 
		keyCode == Keys.VOLUME_UP) {
		
		return false;
	}
	
	synchronized (motionEvents) {
		keysEvents.add( event );
	}
	return true;
}
 
Example #20
Source File: Window.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSignal( Key key ) {
	if (key.pressed) {
		switch (key.code) {
		case Keys.BACK:
			onBackPressed();			
			break;
		case Keys.MENU:
			onMenuPressed();			
			break;
		}
	}
	
	Keys.event.cancel();
}
 
Example #21
Source File: Scene.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void destroy() {
	Keys.event.remove( keyListener );
	super.destroy();
}
 
Example #22
Source File: Scene.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void destroy() {
	Keys.event.remove( keyListener );
	super.destroy();
}
 
Example #23
Source File: Scene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void destroy() {
	Keys.event.remove( keyListener );
	super.destroy();
}