use of com.badlogic.gdx.scenes.scene2d.Actor in project netthreads-libgdx by alistairrutherford.
the class SceneHelper method hit.
/**
* Find hit class.
*
* @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;
}
use of com.badlogic.gdx.scenes.scene2d.Actor in project netthreads-libgdx by alistairrutherford.
the class SceneHelper method hit.
/**
* Look for target hit of specified class.
*
* @param x
* Current x position.
* @param y
* Current y position
* @param stage
* The starting stage.
* @param targetClass
* The target class type.
* @return Target class or null if not found.
*/
@SuppressWarnings("rawtypes")
public static Actor hit(float x, float y, Stage stage, Class targetClass) {
Group root = stage.getRoot();
SnapshotArray<Actor> children = root.getChildren();
Actor hit = null;
boolean found = false;
int index = children.size - 1;
while (!found && index >= 0) {
Actor child = children.get(index);
point.x = x;
point.y = y;
root.localToDescendantCoordinates(child, point);
Actor childHit = root.hit(point.x, point.y, true);
if (childHit != null && childHit.getClass().isAssignableFrom(targetClass)) {
found = true;
hit = childHit;
} else {
index--;
}
}
return hit;
}
use of com.badlogic.gdx.scenes.scene2d.Actor in project Catacomb-Snatch by Catacomb-Snatch.
the class Scene method tick.
@Override
public void tick(float delta) {
// Draw background
if (drawBackground && background != null) {
getBatch().begin();
getBatch().setColor(backgroundColor);
getBatch().draw(background, 0, 0, Screen.getWidth(), Screen.getHeight());
getBatch().end();
}
// Updating mouse dependent stuff in render()
if (!Gdx.input.isTouched()) {
mousePos = screenToStageCoordinates(mousePos.set(Gdx.input.getX(), Gdx.input.getY()));
for (Actor a : getActors()) {
currentActorRect.set(a.getX(), a.getY(), a.getWidth(), a.getHeight());
for (EventListener el : a.getListeners()) {
if (!(el instanceof InputListener))
continue;
InputListener il = (InputListener) el;
if (currentActorRect.contains(mousePos.x, mousePos.y)) {
il.enter(null, mousePos.x, mousePos.y, -1, null);
} else {
il.exit(null, mousePos.x, mousePos.y, -1, null);
}
}
}
}
super.draw();
getBatch().begin();
}
use of com.badlogic.gdx.scenes.scene2d.Actor in project Entitas-Java by Rubentxu.
the class GUIManagerGDX method createGUIElement.
@Override
public Actor createGUIElement(String name) {
GUIFactory<Actor, GUIManagerGDX> factory = guiFactories.get(name);
Actor element = null;
if (factory != null) {
element = factory.create(this);
}
return element;
}
use of com.badlogic.gdx.scenes.scene2d.Actor in project AmazingMaze by TheVirtualMachine.
the class FishMiniGame method setupPauseMenu.
/** Create the pause menu. */
private void setupPauseMenu() {
pauseMenu = new Stage(new ScreenViewport(), game.batch);
Table table = new Table();
table.setFillParent(true);
table.center();
pauseMenu.addActor(table);
TextButton resumeButton = new TextButton("Resume", game.assets.skin);
resumeButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
paused = false;
}
});
table.add(resumeButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
table.row();
TextButton settingsButton = new TextButton("Settings", game.assets.skin);
final Screen sourceScreen = this;
settingsButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
game.settingsScreen.setSourceScreen(sourceScreen);
game.setScreen(game.settingsScreen);
}
});
table.add(settingsButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
table.row();
TextButton quitButton = new TextButton("Quit", game.assets.skin);
quitButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
game.save.setLevel(game.save.getLevel() - 1);
game.setScreen(game.menuScreen);
}
});
table.add(quitButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
}
Aggregations