Java Code Examples for com.watabou.utils.Signal

The following examples show how to use com.watabou.utils.Signal. These examples are extracted from open source projects. 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 Project: YetAnotherPixelDungeon   Source File: Scene.java    License: 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 Project: PD-classes   Source File: Scene.java    License: 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
public void create() {
	Game.instance.getInputProcessor().addKeyListener(keyListener = new Signal.Listener<NoosaInputProcessor.Key>() {
		@Override
		public void onSignal(NoosaInputProcessor.Key key) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
					case Input.Keys.BACK:
					case Input.Keys.ESCAPE:
						onBackPressed();
						break;
					case Input.Keys.MENU:
					case Input.Keys.F5:
						onMenuPressed();
						break;
				}
			}
		}
	});
}
 
Example 4
public void create() {
	KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
		@Override
		public boolean onSignal( KeyEvent event ) {
			if (Game.instance != null && event.pressed) {
				if (KeyBindings.getActionForKey( event ) == GameAction.BACK){
					onBackPressed();
				}
			}
			return false;
		}
	} );
}
 
Example 5
@Override
protected void createChildren() {
	hotArea = new PointerArea( 0, 0, 0, 0 ) {
		@Override
		protected void onPointerDown( PointerEvent event ) {
			pressed = true;
			pressTime = 0;
			processed = false;
			Button.this.onPointerDown();
		}
		@Override
		protected void onPointerUp( PointerEvent event ) {
			pressed = false;
			Button.this.onPointerUp();
		}
		@Override
		protected void onClick( PointerEvent event ) {
			if (!processed) {
				Button.this.onClick();
			}
		}
	};
	add( hotArea );
	
	KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
		@Override
		public boolean onSignal ( KeyEvent event ) {
			if ( active && event.pressed && KeyBindings.getActionForKey( event ) == keyAction()){
				onClick();
				return true;
			}
			return false;
		}
	});
}
 
Example 6
public static void addKeyListener( Signal.Listener<KeyEvent> listener ){
	keySignal.add(listener);
}
 
Example 7
public static void removeKeyListener( Signal.Listener<KeyEvent> listener ){
	keySignal.remove(listener);
}
 
Example 8
public static void addPointerListener( Signal.Listener<PointerEvent> listener ){
	pointerSignal.add(listener);
}
 
Example 9
public static void removePointerListener( Signal.Listener<PointerEvent> listener ){
	pointerSignal.remove(listener);
}
 
Example 10
public static void addScrollListener( Signal.Listener<ScrollEvent> listener ){
	scrollSignal.add(listener);
}
 
Example 11
public static void removeScrollListener( Signal.Listener<ScrollEvent> listener ){
	scrollSignal.remove(listener);
}
 
Example 12
public void addKeyListener(Signal.Listener<Key<T>> listener) {
	eventKey.add(listener);
}
 
Example 13
public void removeKeyListener(Signal.Listener<Key<T>> listener) {
	eventKey.remove(listener);
}
 
Example 14
public void addTouchListener(Signal.Listener<Touch> listener) {
	eventTouch.add(listener);
}
 
Example 15
public void removeTouchListener(Signal.Listener<Touch> listener) {
	eventTouch.remove(listener);
}
 
Example 16
public void addMouseListener(Signal.Listener<PDMouseEvent> listener) {
	eventMouse.add(listener);
}
 
Example 17
public void removeMouseListener(Signal.Listener<PDMouseEvent> listener) {
	eventMouse.remove(listener);
}