Search in sources :

Example 1 with ChangeStateCommand

use of com.ilargia.games.entitas.egdx.api.ChangeStateCommand in project Entitas-Java by Rubentxu.

the class DelaySystem method execute.

@Override
public void execute(float deltatime) {
    for (CoreEntity e : _group.getEntities()) {
        Delay delay = e.getDelay();
        delay.time += deltatime;
        if (delay.time > delay.duration) {
            PongGame.ebus.post((ChangeStateCommand<PongGame>) (nameState, game) -> game.changeState(game.getPongState(), game.getSlideTransition()));
            delay.time = 0;
        }
    }
}
Also used : CoreEntity(com.ilargia.games.entitas.core.CoreEntity) PongGame(com.ilargia.games.entitas.PongGame) ChangeStateCommand(com.ilargia.games.entitas.egdx.api.ChangeStateCommand) Group(com.ilargia.games.entitas.group.Group) CoreMatcher(com.ilargia.games.entitas.core.CoreMatcher) IExecuteSystem(com.ilargia.games.entitas.api.system.IExecuteSystem) CoreContext(com.ilargia.games.entitas.core.CoreContext) Delay(com.ilargia.games.logicbrick.component.Delay) CoreEntity(com.ilargia.games.entitas.core.CoreEntity) Delay(com.ilargia.games.logicbrick.component.Delay) PongGame(com.ilargia.games.entitas.PongGame)

Example 2 with ChangeStateCommand

use of com.ilargia.games.entitas.egdx.api.ChangeStateCommand in project Entitas-Java by Rubentxu.

the class MenuState method init.

@Override
public void init() {
    Gdx.app.log("Menu", "Init");
    int pad = (int) (20 * SMGUIManager.ScaleUtil.getSizeRatio());
    int pad2 = (int) (60 * SMGUIManager.ScaleUtil.getSizeRatio());
    final TextButton btnStart = new TextButton("Comenzar", skin);
    btnStart.pad(pad, pad2, pad, pad2);
    final TextButton btnOptions = new TextButton("Opciones", skin);
    btnOptions.pad(pad, pad2, pad, pad2);
    final TextButton btnScores = new TextButton("Puntuaciones", skin);
    btnScores.pad(pad, pad2, pad, pad2);
    final TextButton button3 = new TextButton("Creditos", skin);
    button3.pad(pad, pad2, pad, pad2);
    button3.setChecked(false);
    btnStart.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            System.out.println("Click Comenzar...");
        }
    });
    btnOptions.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            System.out.println("Click optionScreen...");
            SMGame.ebus.post((ChangeStateCommand<SMGame>) (nameState, game) -> game.changeState(game.getOptionState(), game.getFadeTransition()));
        }
    });
    btnScores.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            System.out.println("Click highScoreScreen...");
            SMGame.ebus.post((ChangeStateCommand<SMGame>) (nameState, game) -> game.changeState(game.getScoresState(), game.getSlideTransition()));
        }
    });
    Label label = new Label("SUPER MARIANO", skin, "header", Color.CYAN);
    label.setAlignment(Align.center, Align.center);
    mainTable.defaults().padBottom(pad);
    if (Gdx.graphics.getHeight() < 480)
        mainTable.defaults().height(Gdx.graphics.getHeight() / 5f - pad);
    mainTable.add(label);
    mainTable.row();
    mainTable.add(btnStart);
    mainTable.row();
    mainTable.add(btnOptions);
    mainTable.row();
    mainTable.add(btnScores);
    mainTable.row();
    mainTable.add(button3);
    mainTable.row();
    mainTable.setBackground(new SpriteDrawable(new Sprite((Texture) assetsManager.getTexture(SMGUIManager.MENU_BACKGROUND))));
    mainTable.row();
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) SpriteDrawable(com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) ChangeStateCommand(com.ilargia.games.entitas.egdx.api.ChangeStateCommand) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

ChangeStateCommand (com.ilargia.games.entitas.egdx.api.ChangeStateCommand)2 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 SpriteDrawable (com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable)1 PongGame (com.ilargia.games.entitas.PongGame)1 IExecuteSystem (com.ilargia.games.entitas.api.system.IExecuteSystem)1 CoreContext (com.ilargia.games.entitas.core.CoreContext)1 CoreEntity (com.ilargia.games.entitas.core.CoreEntity)1 CoreMatcher (com.ilargia.games.entitas.core.CoreMatcher)1 Group (com.ilargia.games.entitas.group.Group)1 Delay (com.ilargia.games.logicbrick.component.Delay)1