Java Code Examples for com.badlogic.gdx.InputProcessor

The following are top voted examples for showing how to use com.badlogic.gdx.InputProcessor. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Roguelike   File: OptionsScreen.java   View source code 6 votes vote down vote up
public void create()
{
	skin = Global.loadSkin();

	stage = new Stage( new ScreenViewport() );
	batch = new SpriteBatch();

	table = new Table();
	stage.addActor( table );
	table.setFillParent( true );

	inputMultiplexer = new InputMultiplexer();

	InputProcessor inputProcessorOne = this;
	InputProcessor inputProcessorTwo = stage;

	inputMultiplexer.addProcessor( inputProcessorTwo );
	inputMultiplexer.addProcessor( inputProcessorOne );
}
 
Example 2
Project: GeographyMap   File: Checkbox.java   View source code 6 votes vote down vote up
public Checkbox(int upY, int x, int width){
    this.x = x;
    this.width = width;
    koef = AssetLoader.alumT.getRegionWidth()/width;
    height = (int)(AssetLoader.alumT.getRegionHeight()/koef);
    titleY = upY - height;
    stalY = titleY - height;
    alumY = stalY - height - 2;
    autoY = alumY - height - 2;
    sudY = autoY - height - 2;
    minudY = sudY - height - 2;
    himY = minudY - height - 2;
    layerHeight = upY;
    Array<InputProcessor> inputProcessorArray=GeographyMapMainClass.inputMultiplexer.getProcessors();
    for (int i = 0; i < inputProcessorArray.size; i++) {
        if(inputProcessorArray.get(i) instanceof InputListener){
            inputProcessorArray.removeIndex(i);
            i--;
        }
    }
    GeographyMapMainClass.inputMultiplexer.addProcessor(new InputListener(x, stalY, alumY, autoY, sudY, minudY, himY, width, height));
}
 
Example 3
Project: gdx.automation   File: InputProcessorProxy.java   View source code 6 votes vote down vote up
public static boolean removeProxyFromGdxInput(InputProcessorProxy proxy) {
	if (Gdx.input == null) {
		return false;
	}
	if (Gdx.input.getInputProcessor() == null) {
		return false;
	}
	if (Gdx.input.getInputProcessor().equals(proxy)) {
		Gdx.input.setInputProcessor(proxy.getProxied());
		return true;
	}
	InputProcessor current = Gdx.input.getInputProcessor();
	InputProcessorProxy asProxy;
	while (current != null && current instanceof InputProcessorProxy) {
		asProxy = (InputProcessorProxy) current;
		if (asProxy.getProxied().equals(proxy)) {
			asProxy.setProxied(proxy.getProxied());
			return true;
		}
		current = asProxy.getProxied();
	}
	return false;
}
 
Example 4
Project: gdx.automation   File: InputProcessorProxyTest.java   View source code 6 votes vote down vote up
@Test
public void testRemoveProxyFromGdxInput() {
	Gdx.input = new InputProxy() {
		private InputProcessor processor;

		@Override
		public void setInputProcessor(InputProcessor processor) {
			this.processor = processor;
		}

		@Override
		public InputProcessor getInputProcessor() {
			return processor;
		}
	};
	InputProcessorProxy proxy = new InputProcessorProxy(testProcessor) {
	};
	Gdx.input.setInputProcessor(proxy);
	assertTrue(InputProcessorProxy.removeProxyFromGdxInput(proxy));
	assertEquals(testProcessor, Gdx.input.getInputProcessor());
}
 
Example 5
Project: GDX-Logic-Bricks   File: LogicBricksEngine.java   View source code 6 votes vote down vote up
@Override
public void addSystem(EntitySystem system) {
    super.addSystem(system);
    if (EntityListener.class.isInstance(system)) {
        this.addEntityListener((EntityListener) system);

    }
    if (InputProcessor.class.isInstance(system)) {
        inputs.addProcessor((InputProcessor) system);

    }
    if (ContactListener.class.isInstance(system)) {
        contactSystems.add((ContactListener) system);

    }

}
 
Example 6
Project: school-game   File: InputManager.java   View source code 5 votes vote down vote up
/**
 * Initialisierung.
 *
 * Lädt alle angeschlossenen Controller und legt den InputProcessor fest.
 *
 * @param inputProcessor der InputProcessor an den Controllereingaben gesendet werden sollen
 */
public void init(InputProcessor inputProcessor)
{
    this.feedForwardProcessor = inputProcessor;

    for (Controller controller : Controllers.getControllers())
    {
        loadController(controller);
    }

    buildInverse();
}
 
Example 7
Project: Argent   File: Argent.java   View source code 5 votes vote down vote up
public static void attachInputProcessor(InputProcessor proc) {
    InputProcessor processor = Gdx.input.getInputProcessor();
    if(processor.equals(proc)) return;
    if(processor instanceof InputMultiplexer) {
        if(!((InputMultiplexer) processor).getProcessors().contains(proc, true))
            ((InputMultiplexer) processor).addProcessor(proc);
    }else{
        InputMultiplexer multiplexer = new InputMultiplexer(processor, proc);
        Gdx.input.setInputProcessor(multiplexer);
    }
}
 
Example 8
Project: libgdxjam   File: GameScreen.java   View source code 5 votes vote down vote up
private void addInputProcessors() {
	logger.info("enabling engine input processors");
	InputMultiplexer inputMultiplexer = Env.getGame().getMultiplexer();
	
	inputMultiplexer.addProcessor(this);
	
	for (EntitySystem system : engine.getSystems()) {
		if (system instanceof InputProcessor) {
			inputMultiplexer.addProcessor((InputProcessor)system);
		}
	}
}
 
Example 9
Project: libgdxjam   File: GameScreen.java   View source code 5 votes vote down vote up
private void removeInputProcessors() {
	logger.info("disabling engine input processors");
	InputMultiplexer inputMultiplexer = Env.getGame().getMultiplexer();
	
	inputMultiplexer.removeProcessor(this);
	
	for (EntitySystem system : engine.getSystems()) {
		if (system instanceof InputProcessor) {
			inputMultiplexer.removeProcessor((InputProcessor)system);
		}
	}
}
 
Example 10
Project: gdx-backend-jglfw   File: JglfwInput.java   View source code 5 votes vote down vote up
public GlfwInputProcessor(long window, JglfwGraphics graphics, InputProcessor processor) {
	if (processor == null) throw new IllegalArgumentException("processor cannot be null.");
	this.graphics = graphics;
	this.processor = processor;

	glfwSetCharCallback(window, charCallback);
	glfwSetKeyCallback(window, keyCallback);
	glfwSetScrollCallback(window, scrollCallback);
	glfwSetMouseButtonCallback(window, mouseButtonCallback);
	glfwSetCursorPosCallback(window, cursorPosCallback);
}
 
Example 11
Project: libgdx-inGameConsole   File: GUIConsole.java   View source code 5 votes vote down vote up
/** Compares the given processor to the console's stage. If given a multiplexer, it is iterated through recursively to check all
 * of the multiplexer's processors for comparison.
 *
 * @param processor
 * @return processor == this.stage */
private boolean hasStage (InputProcessor processor) {
	if (!(processor instanceof InputMultiplexer)) {
		return processor == stage;
	}
	InputMultiplexer im = (InputMultiplexer)processor;
	Array<InputProcessor> ips = im.getProcessors();
	for (InputProcessor ip : ips) {
		if (hasStage(ip)) {
			return true;
		}
	}
	return false;
}
 
Example 12
Project: Roguelike   File: GameScreen.java   View source code 5 votes vote down vote up
private void create()
{
	batch = new SpriteBatch();

	font = AssetManager.loadFont( "Sprites/Unpacked/font.ttf", 12, new Color( 1f, 0.9f, 0.8f, 1 ), 1, Color.BLACK, false );
	hightlightfont = AssetManager.loadFont( "Sprites/Unpacked/font.ttf", 12, new Color( 1f, 1f, 0.9f, 1 ), 1, Color.BLACK, false );

	blank = AssetManager.loadTextureRegion( "Sprites/blank.png" );
	white = AssetManager.loadTextureRegion( "Sprites/white.png" );
	bag = AssetManager.loadSprite( "Oryx/uf_split/uf_items/satchel" );
	bag.drawActualSize = true;
	border = AssetManager.loadSprite( "GUI/frame" );
	speechBubbleArrow = AssetManager.loadTextureRegion( "Sprites/GUI/SpeechBubbleArrow.png" );
	speechBubbleBackground = new NinePatch( AssetManager.loadTextureRegion( "Sprites/GUI/SpeechBubble.png" ), 10, 10, 10, 10 );
	fogSprite = new TilingSprite( "fog", "Masks/fog", "Masks/fog" );

	gestureDetector = new GestureDetector( this );
	gestureDetector.setLongPressSeconds( 0.5f );

	inputMultiplexer = new InputMultiplexer();

	LoadUI();

	InputProcessor inputProcessorOne = this;
	InputProcessor inputProcessorTwo = stage;

	inputMultiplexer.addProcessor( inputProcessorTwo );
	inputMultiplexer.addProcessor( gestureDetector );
	inputMultiplexer.addProcessor( inputProcessorOne );
}
 
Example 13
Project: droidtowers   File: InputSystem.java   View source code 5 votes vote down vote up
public void removeInputProcessor(InputProcessor inputProcessor) {
	for (InputProcessorEntry processorEntry : inputProcessors) {
		if (processorEntry.getInputProcessor() == inputProcessor) {
			processorEntry.markForRemoval();
		}
	}
}
 
Example 14
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
/**
 * Singleton Konstruktor.
 */
private InputManager() {
	InputProcessor defaultInputProcessor = new DefaultInputProcessor();
	addInputProcessor(defaultInputProcessor);
	Gdx.input.setCatchBackKey(true);
	Gdx.input.setInputProcessor(this);
}
 
Example 15
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
/**
 * Diese Methode löscht alle aktiven InputProcessoren.
 */
public static void clear() {
	processors.clear();
	InputProcessor defaultInputProcessor = new DefaultInputProcessor();
	addInputProcessor(defaultInputProcessor);
	Gdx.input.setCatchBackKey(true);
	Gdx.input.setInputProcessor(instance);
}
 
Example 16
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean keyDown(final int keycode) {

	for (InputProcessor processor : processors) {
		if (processor.keyDown(keycode)) {
			return true;
		}
	}
	return false;
}
 
Example 17
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean keyUp(final int keycode) {

	for (InputProcessor processor : processors) {
		if (processor.keyUp(keycode)) {
			return true;
		}
	}
	return false;
}
 
Example 18
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean keyTyped(final char character) {

	for (InputProcessor processor : processors) {
		if (processor.keyTyped(character)) {
			return true;
		}
	}
	return false;
}
 
Example 19
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean touchDown(final int screenX, final int screenY, final int pointer, final int button) {

	for (InputProcessor processor : processors) {
		if (processor.touchDown(screenX, screenY, pointer, button)) {
			return true;
		}
	}
	return false;
}
 
Example 20
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean touchUp(final int screenX, final int screenY, final int pointer, final int button) {

	for (InputProcessor processor : processors) {
		if (processor.touchUp(screenX, screenY, pointer, button)) {
			return true;
		}

	}
	return false;
}
 
Example 21
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean touchDragged(final int screenX, final int screenY, final int pointer) {

	for (InputProcessor processor : processors) {
		if (processor.touchDragged(screenX, screenY, pointer)) {
			return true;
		}
	}
	return false;
}
 
Example 22
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean mouseMoved(final int screenX, final int screenY) {

	for (InputProcessor processor : processors) {
		if (processor.mouseMoved(screenX, screenY)) {
			return true;
		}
	}
	return false;
}
 
Example 23
Project: HAW-SE2-projecthorse   File: InputManager.java   View source code 5 votes vote down vote up
@Override
public boolean scrolled(final int amount) {

	for (InputProcessor processor : processors) {
		if (processor.scrolled(amount)) {
			return true;
		}
	}
	return false;
}
 
Example 24
Project: dynamicpool   File: WorldController.java   View source code 5 votes vote down vote up
public void addFishButtonClick() {
	if (this.addingFishStep == 0) {
		this.addingFishStep = 1;
	} else {
		this.addingFishStep = 0;
	}
	InputProcessor selectFishInputProcessor = gameScreen
			.getSelectFishInputProcessor();
	this.setGameInputProcessor(selectFishInputProcessor);
}
 
Example 25
Project: dynamicpool   File: WorldController.java   View source code 5 votes vote down vote up
public void selectFish(FishType fishType) {
	this.selectedFishType = fishType;
	this.addingFishStep = 2;
	InputProcessor selectTrajectoryInputProcessor = gameScreen
			.getSelectTrajectoryInputProcessor();
	this.setGameInputProcessor(selectTrajectoryInputProcessor);
}
 
Example 26
Project: gdx.automation   File: InputProxy.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
	if (input != null) {
		return input.getInputProcessor();
	} else {
		return null;
	}
}
 
Example 27
Project: c2d-engine   File: ActionShake.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
    return new InputAdapter() {
        @Override
        public boolean touchUp(int x, int y, int pointer, int button) {
            shake();
            return super.touchUp(x, y, pointer, button);
        }
    };
}
 
Example 28
Project: c2d-engine   File: ParallaxGroupGestureDetectorTest.java   View source code 5 votes vote down vote up
@Override
public void onLoadedResourcesCompleted() {
    final TextureAtlas bgAtlas = Engine.resource("bgAtlas", TextureAtlas.class);
    rbg = new ParallaxGroup(480, 320, new Vector2(50, 100));
    rbg.addActor(new Image(new AdvanceSprite(bgAtlas.findRegion("bg"))));
    rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("cloud"))), new Vector2(0.5f, 0), new Vector2(0, 1000), new Vector2(0, 70)));
    rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("front"))), new Vector2(1f, 0), new Vector2(0, 1000), new Vector2()));

    rbg.setScale(Engine.getWidth() / 480f);

    rbg.setSpeed(0, 0);

    final SceneStage stage = new SceneStage() {
        @Override
        public InputProcessor getInputProcessor() {
            DefaultParallaxGroupGestureListener gestureListener = new DefaultParallaxGroupGestureListener(rbg);
            rbg.setDefaultGestureDetector(gestureListener);
            return rbg.getGestureDetector();
        }

        @Override
        public void render(float delta) {
            super.render(delta);
            Engine.debugInfo("The parallax background with layer number:" + rbg.getChildren().size + "\n" +
                    "GestureDetector by make a gesture use your mouse or your finger\n");
        }
    };
    stage.addActor(rbg);

    Engine.setMainScene(stage);
}
 
Example 29
Project: c2d-engine   File: SceneB.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
    return new InputAdapter() {
        @Override
        public boolean touchUp(int x, int y, int pointer, int button) {
            Engine.setMainScene(SceneA.getInstance(), ((AbstractTransiton) Engine.get()).b2a());
            return super.touchUp(x, y, pointer, button);
        }
    };
}
 
Example 30
Project: c2d-engine   File: SceneA.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
    return new InputAdapter() {
        @Override
        public boolean touchUp(int x, int y, int pointer, int button) {
            Engine.setMainScene(SceneB.getInstance(), ((AbstractTransiton) Engine.get()).a2b());
            return super.touchUp(x, y, pointer, button);
        }
    };
}
 
Example 31
Project: c2d-engine   File: SceneHelper.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
    input.clear();
    input.addProcessor(this);
    input.addProcessor(bodySelectInput);
    return input;
}
 
Example 32
Project: c2d-engine   File: SimulationScene.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
    if (null == screenBox) {
        return null;
    }
    mouseJointInput.setFixBody(screenBox);
    mouseJointInput.setWorld(PhysicalWorld.WORLD);
    return mouseJointInput;
}
 
Example 33
Project: c2d-engine   File: SceneGroup.java   View source code 5 votes vote down vote up
@Override
public InputProcessor getInputProcessor() {
	if(this.size>0){
		input.clear();
		for(int i=this.size-1;i>=0;i--){
			if(null!=this.get(i).getInputProcessor()){
				input.addProcessor(this.get(i).getInputProcessor());
			}
		}
		return input;
	}
	return null;
}
 
Example 34
Project: ProjektGG   File: GameInputProcessor.java   View source code 4 votes vote down vote up
public void setInputProcessor(InputProcessor inputProcessor) {
	this.inputProcessor = inputProcessor;
}
 
Example 35
Project: cocos2d-java   File: BaseInput.java   View source code 4 votes vote down vote up
public final int addInputProcessor(int index, InputProcessor processor) {
	_multiplexer.addProcessor(index, processor);
	return index;
}
 
Example 36
Project: cocos2d-java   File: BaseInput.java   View source code 4 votes vote down vote up
public final int pushInputProcessor(InputProcessor processor) {
	_multiplexer.addProcessor(0, processor);
	return 0;
}
 
Example 37
Project: cocos2d-java   File: BaseInput.java   View source code 4 votes vote down vote up
public final int addInputProcessor(InputProcessor processor) {
	int ret = _multiplexer.size();
	_multiplexer.addProcessor(processor);
	return ret;
}
 
Example 38
Project: cocos2d-java   File: BaseInput.java   View source code 4 votes vote down vote up
public final void removeInputProcessor(InputProcessor processor) {
	_multiplexer.removeProcessor(processor);
}
 
Example 39
Project: penguins-in-space   File: BaseView.java   View source code 4 votes vote down vote up
@Override
public final InputProcessor getInputProcessor() {
    return this;
}
 
Example 40
Project: MMORPG_Prototype   File: InputMultiplexer.java   View source code 4 votes vote down vote up
public InputMultiplexer(InputProcessor... processors)
{
	for (int i = 0; i < processors.length; i++)
		this.processors.add(processors[i]);
}