List of usage examples for com.badlogic.gdx.scenes.scene2d Actor hit
public Actor hit(float x, float y, boolean touchable)
From source file:com.netthreads.libgdx.scene.SceneHelper.java
License:Apache License
/** * Find hit class./* ww w . ja v a 2 s . c om*/ * * @param x Current x position. * @param y Current y position * @param group The starting Group. * @param targetClass The target class type. * @return The target or null if not found. */ @SuppressWarnings("rawtypes") public static Actor hit(float x, float y, Group group, Class targetClass) { SnapshotArray<Actor> children = group.getChildren(); Actor hit = null; boolean found = false; int index = children.size - 1; while (!found && index >= 0) { Actor child = children.get(index); if (child.getClass().isAssignableFrom(targetClass)) { point.x = x; point.y = y; group.localToDescendantCoordinates(child, point); if (child.hit(point.x, point.y, true) != null) { found = true; hit = child; } else if (child instanceof Group) { child = hit(x, y, (Group) child, targetClass); } } index--; } return hit; }
From source file:com.strategames.engine.scenes.scene2d.Stage.java
License:Open Source License
public Array<Actor> getActorsAt(float x, float y) { Array<Actor> actors = getActors(); Array<Actor> actorsHit = new Array<Actor>(); Vector2 point = new Vector2(); for (int i = 0; i < actors.size; i++) { Actor actor = actors.get(i); actor.parentToLocalCoordinates(point.set(x, y)); if (actor.hit(point.x, point.y, false) != null) { actorsHit.add(actor);/* w w w.ja va2 s. c o m*/ } } return actorsHit; }
From source file:com.turbogerm.germlibrary.controls.CustomImageButton.java
License:Open Source License
private static InputListener getInputListener(final Actor actor, final CustomButtonAction action) { return new InputListener() { @Override//from w w w. j av a2 s . c o m public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { action.invoke(); } } }; }
From source file:com.turbogerm.suchyblocks.screens.GameOverScreen.java
License:Open Source License
private InputListener getContinueInputListener(final Actor actor) { return new InputListener() { @Override// w w w .j a v a2 s. co m public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { mGameData.getHighScoresData().insertHighScore(mNameTextField.getText(), mGameData.getScore()); mGame.setScreen(SuchyBlocks.HIGH_SCORE_SCREEN_NAME); } } }; }
From source file:com.turbogerm.suchyblocks.screens.HighScoreScreen.java
License:Open Source License
private InputListener getBackInputListener(final Actor actor) { return new InputListener() { @Override// ww w . j a v a 2 s . com public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { mGame.setScreen(SuchyBlocks.MAIN_MENU_SCREEN_NAME); } } }; }
From source file:com.turbogerm.suchyblocks.screens.MainMenuScreen.java
License:Open Source License
private InputListener getStartInputListener(final Actor actor) { return new InputListener() { @Override//from w w w . j a va 2 s. c om public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { mGame.setScreen(SuchyBlocks.PLAY_SCREEN_NAME); } } }; }
From source file:com.turbogerm.suchyblocks.screens.MainMenuScreen.java
License:Open Source License
private InputListener getHighScoreInputListener(final Actor actor) { return new InputListener() { @Override//from ww w . ja v a 2 s.co m public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { mGame.setScreen(SuchyBlocks.HIGH_SCORE_SCREEN_NAME); } } }; }
From source file:com.turbogerm.suchyblocks.screens.MainMenuScreen.java
License:Open Source License
private InputListener getInfoInputListener(final Actor actor) { return new InputListener() { @Override//from ww w . ja v a 2s . c o m public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { mGame.setScreen(SuchyBlocks.INFO_SCREEN_NAME); } } }; }
From source file:com.turbogerm.suchyblocks.screens.PlayScreen.java
License:Open Source License
private InputListener getPlayPauseInputListener(final Actor actor) { return new InputListener() { @Override/* w ww.j a v a2 s . c o m*/ public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (actor.hit(x, y, true) != null) { togglePause(); } } }; }
From source file:es.eucm.ead.editor.view.builders.scene.groupeditor.inputstatemachine.InputState.java
License:Open Source License
protected boolean isTouchCancelled(InputEvent event, float x, float y) { Actor actor = event.getTarget(); Actor hit = actor.hit(x, y, true); return !(hit == actor || (hit != null && hit.isDescendantOf(actor))); }