use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.
the class PantallaSurvival method crearMenu.
private void crearMenu() {
stageMenu = new Stage(vista);
imgBackground = new Texture("Background.png");
spriteBackground = new Sprite(imgBackground);
spriteBackground.setPosition(0, 0);
imgLogo = new Texture("LOGO-2.png");
spriteLogo = new Sprite(imgLogo);
spriteLogo.setPosition(ANCHO / 2 - spriteLogo.getWidth() / 2, ALTO - spriteLogo.getHeight() - 50);
// Boton Play
TextureRegionDrawable trdPlay = new TextureRegionDrawable(new TextureRegion(new Texture("button_start.png")));
TextureRegionDrawable trdPlayPressed = new TextureRegionDrawable(new TextureRegion(new Texture("button_start_pressed.png")));
ImageButton btnPlay = new ImageButton(trdPlay, trdPlayPressed);
btnPlay.setPosition(ANCHO / 2 - btnPlay.getWidth() / 2, ALTO / 4 - btnPlay.getHeight() / 2);
// Boton Leaderboard
TextureRegionDrawable trdLead = new TextureRegionDrawable(new TextureRegion(new Texture("but-lead.png")));
TextureRegionDrawable trdLeadPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-lead-push.png")));
ImageButton btnLead = new ImageButton(trdLead, trdLeadPush);
btnLead.setPosition(ANCHO / 4 - btnLead.getWidth() / 2, ALTO / 4 - btnLead.getHeight() / 2);
// Boton Config
TextureRegionDrawable trdConfig = new TextureRegionDrawable(new TextureRegion(new Texture("but-config.png")));
TextureRegionDrawable trdConfigPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-config-push.png")));
ImageButton btnConfig = new ImageButton(trdConfig, trdConfigPush);
btnConfig.setPosition(ANCHO * 3 / 4 - btnConfig.getWidth() / 2, ALTO / 4 - btnConfig.getHeight() / 2);
// Boton Tutorial
TextureRegionDrawable trdTut = new TextureRegionDrawable(new TextureRegion(new Texture("but-tut.png")));
TextureRegionDrawable trdTutPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-tut-push.png")));
ImageButton btnTut = new ImageButton(trdTut, trdTutPush);
btnTut.setPosition(ANCHO * 9 / 10 - btnTut.getWidth() / 2, ALTO * 9 / 10 - btnTut.getHeight() / 2);
// Click en boton Play
btnPlay.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
dispose();
main.setScreen(new PantallaJuego(main));
}
});
// Click en boton Lead
btnLead.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
dispose();
main.setScreen(new PantallaScoresStory(main));
}
});
// Click en boton Tutorial
btnTut.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
dispose();
main.setScreen(new PantallaTutorialStoryMode(main));
}
});
// Click en boton Config
btnConfig.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
dispose();
main.setScreen(new PantallaDeveloper(main));
}
});
stageMenu.addActor(btnPlay);
stageMenu.addActor(btnLead);
stageMenu.addActor(btnConfig);
stageMenu.addActor(btnTut);
Gdx.input.setInputProcessor(stageMenu);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project var3dframe by Var3D.
the class StageTest method init.
@Override
public void init() {
// 设置背景
setBackground(R.image.bg);
// 设置标题
txt_logo = game.getLabel(R.strings.logo).setColor(Color.BLUE).setStroke(Color.CYAN).setPosition(getWidth() / 2, getHeight() - 20, Align.top).setAlpha(0.9f).touchOff().show();
// Tost
btn_tost = game.getButton(R.image.pause_btn_bg).setPosition(0, 380).addClicAction().show();
btn_tost.add(game.getLabel(R.strings.tost).getActor());
btn_tost.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
game.setUserData(DialogMessge.MODEL, new DialogMessge.Model("这是一个Tost范例"));
game.showDialog(DialogMessge.class);
}
});
// 自定义对话框
btn_dialog = game.getButton(R.image.pause_btn_bg).setPosition(0, 320).addClicAction().show();
btn_dialog.add(game.getLabel(R.strings.dialogTitle).getActor());
btn_dialog.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
game.showDialog(DialogTest.class);
}
});
// shader测试
WaterActor waterActor = game.getUI(new WaterActor(game.getTextureRegion(R.image.badlogic))).show(Align.center);
OutLineActor outLineActor = game.getUI(new OutLineActor(game.getTextureRegion(R.image.tank_4))).setPosition(getWidth() / 2, waterActor.getY() - 10, Align.top).show();
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Entitas-Java by Rubentxu.
the class GuiFactory method createPadButtons.
public Table createPadButtons(float width, float height, InputEntity player) {
Table tableControlPad = new Table();
PlayerInputController stateController = player.getPlayerInputController();
tableControlPad.row().height(height);
ImageButton btnLeft = new ImageButton(skin, "buttonLeft");
tableControlPad.add(btnLeft).width(width).expandY().fill();
btnLeft.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.leftPressed();
// controller.rightReleased();
player.replacePlayerInputController(true, false, stateController.jumpPressed);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.leftReleased();
player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.rightReleased();
// controller.leftPressed();
player.replacePlayerInputController(true, false, stateController.jumpPressed);
} else {
// controller.leftReleased();
player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
}
}
});
ImageButton btnRight = new ImageButton(skin, "buttonRight");
tableControlPad.add(btnRight).width(width).expandY().fill().padRight((width) * 2);
btnRight.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.leftReleased();
// controller.rightPressed();
player.replacePlayerInputController(false, true, stateController.jumpPressed);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.rightReleased();
player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.rightPressed();
// controller.leftReleased();
player.replacePlayerInputController(false, true, stateController.jumpPressed);
} else {
// controller.rightReleased();
player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
}
}
});
ImageButton btnUP = new ImageButton(skin, "buttonUp");
tableControlPad.add(btnUP).width(width).expandY().fill();
btnUP.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.jumpPressed();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.jumpReleased();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.jumpPressed();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
} else {
// controller.jumpReleased();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
}
}
});
tableControlPad.setBounds(0, 0, Gdx.graphics.getWidth(), height + 10);
return tableControlPad;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Entitas-Java by Rubentxu.
the class GuiFactory method createPadButtons.
public Table createPadButtons(float width, float height, InputEntity player) {
Table tableControlPad = new Table();
PlayerInputController stateController = player.getPlayerInputController();
tableControlPad.row().height(height);
ImageButton btnLeft = new ImageButton(skin, "buttonLeft");
tableControlPad.add(btnLeft).width(width).expandY().fill();
btnLeft.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.leftPressed();
// controller.rightReleased();
player.replacePlayerInputController(true, false, stateController.jumpPressed);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.leftReleased();
player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.rightReleased();
// controller.leftPressed();
player.replacePlayerInputController(true, false, stateController.jumpPressed);
} else {
// controller.leftReleased();
player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
}
}
});
ImageButton btnRight = new ImageButton(skin, "buttonRight");
tableControlPad.add(btnRight).width(width).expandY().fill().padRight((width) * 2);
btnRight.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.leftReleased();
// controller.rightPressed();
player.replacePlayerInputController(false, true, stateController.jumpPressed);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.rightReleased();
player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.rightPressed();
// controller.leftReleased();
player.replacePlayerInputController(false, true, stateController.jumpPressed);
} else {
// controller.rightReleased();
player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
}
}
});
ImageButton btnUP = new ImageButton(skin, "buttonUp");
tableControlPad.add(btnUP).width(width).expandY().fill();
btnUP.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchDown(event, x, y, pointer, button);
// controller.jumpPressed();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
System.out.println("Event " + event.getType());
super.touchUp(event, x, y, pointer, button);
// controller.jumpReleased();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
System.out.println("Event- " + event.getType());
super.touchDragged(event, x, y, pointer);
if (isOver(event.getListenerActor(), x, y)) {
// controller.jumpPressed();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
} else {
// controller.jumpReleased();
player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
}
}
});
tableControlPad.setBounds(0, 0, Gdx.graphics.getWidth(), height + 10);
return tableControlPad;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Eidolons by IDemiurge.
the class ActionValueContainer method init.
@Override
protected void init(TextureRegion texture, String name, String value) {
super.init(texture, name, value);
clickAction = () -> {
};
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
clickAction.run();
}
});
}
Aggregations