当前位置: 首页>>代码示例>>Java>>正文


Java TextButton.addCaptureListener方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextButton.addCaptureListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextButton.addCaptureListener方法的具体用法?Java TextButton.addCaptureListener怎么用?Java TextButton.addCaptureListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.ui.TextButton的用法示例。


在下文中一共展示了TextButton.addCaptureListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PlayGroup

import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //导入方法依赖的package包/类
public PlayGroup(Client client) {
    play = new TextButton("Play", Assets.SKIN);
    play.setSize(200, 40);
    play.setPosition((Gdx.graphics.getWidth() - play.getWidth()) / 2, Gdx.graphics.getHeight() / 8);

    port = new NumberField(null, Assets.SKIN);
    port.setPosition(play.getX(), play.getY() + port.getHeight() * 1.1f);
    port.setBounds(port.getX(), port.getY(), play.getWidth(), play.getHeight());

    host = new TextField(null, Assets.SKIN);
    host.setSize(200, 40);
    host.setPosition(play.getX(), port.getY() + host.getHeight() * 1.1f);

    hostLabel = new ConquestLabel("Host:", host.getX() - 75, host.getY() - 5, 50, 50);
    portLabel = new ConquestLabel("Port:", hostLabel.getX(), port.getY() - 5, 50, 50);

    server = new ConquestLabel("Failed to connect.", play.getX(), host.getY() + 75, 200, 1);
    server.setVisible(false);

    play.addCaptureListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            try {
                client.connect(host.getText(), port.getValue());
            } catch (IOException io) {
                server.setVisible(true);
                Timer.schedule(new Timer.Task() {
                    @Override
                    public void run() {
                        server.setVisible(false);
                    }
                }, 1);
            }
        }
    });

    addActor(play);
    addActor(port);
    addActor(portLabel);
    addActor(host);
    addActor(hostLabel);
    addActor(server);
}
 
开发者ID:conquest,项目名称:conquest,代码行数:43,代码来源:PlayGroup.java

示例2: initGuiGameOver

import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //导入方法依赖的package包/类
private void initGuiGameOver() {
    mGuiGameOverStage = new Stage(new ScreenViewport());

    Table rootTable = new Table();
    if (DEBUG_RENDERER) {
        rootTable.debug();
    }

    // add margin on the bottom for iOS
    final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0;

    final float dialogMargin = 50.f;
    final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f);
    final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset;

    rootTable.setWidth(dialogWidth);
    rootTable.setHeight(dialogHeight);
    rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset);

    rootTable.background(
            new NinePatchDrawable(
                    new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24)));

    Label label = new Label("GAME OVER", mSkin);
    label.setFontScale(2.f);
    label.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
    rootTable.add(label).expand().padTop(dialogHeight * 0.025f);

    rootTable.row();

    TextButton restartButton = new TextButton("RESTART", mSkin);
    restartButton.getLabel().setFontScale(1.f);
    restartButton.getLabel().setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
    restartButton.addCaptureListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            onStartGame();
        }
    });

    Array<Integer> highScores = fetchHighScores();

    mHighScoreLabel = new Array<Label>();

    for (int i = 0; i < highScores.size; i++) {
        Label scoreLabel = new Label("high score: " + highScores.get(i), mSkin);
        scoreLabel.setFontScale(1.0f);
        scoreLabel.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT));
        rootTable.add(scoreLabel).expand();
        rootTable.row();

        mHighScoreLabel.add(scoreLabel);
    }

    // don't like the scene2d interface, if has bad defaults and documentation
    // try to correctly position the bottom restart button
    rootTable.add(restartButton).expand().width(
            dialogWidth - (dialogMargin * 4.f)).height(dialogHeight * 0.1f).bottom().padBottom(dialogHeight * 0.05f);

    mGuiGameOverStage.addActor(rootTable);
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:62,代码来源:Balanceball.java

示例3: create

import com.badlogic.gdx.scenes.scene2d.ui.TextButton; //导入方法依赖的package包/类
@Override
public void create() {
    Stage stage = new Stage(new ScreenViewport());

    getComponentByType(GuiComponent.class).stage = stage;

    Table rootTable = new Table();
    // add margin on the bottom for iOS
    final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0;

    final float dialogMargin = 50.f;
    final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f);
    final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset;

    mDefaultMargin = dialogWidth * 0.03f;

    rootTable.setWidth(dialogWidth);
    rootTable.setHeight(dialogHeight);
    rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset);

    rootTable.background(
            new NinePatchDrawable(
                    new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24)));

    // HEADER
    Label label = new Label("LEADERBOARD", mSkin);
    label.setFontScale(1.6f);
    label.setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
    rootTable.add(label)
            .expand(true, false)
            .padTop(dialogHeight * 0.05f)
            .padBottom(mDefaultMargin * 0.5f);

    rootTable.row();

    mScrollPaneTable = new Table(mSkin);
    ScrollPane scrollPane = new ScrollPane(mScrollPaneTable);

    rootTable.add(scrollPane)
            .fill()
            .expand()
            .padTop(mDefaultMargin * 0.5f)
            .padBottom(mDefaultMargin * 0.5f);
    rootTable.row();

    // RESTART button
    TextButton restartButton = new TextButton("RESTART", mSkin);
    restartButton.getLabel().setFontScale(1.f);
    restartButton.getLabel().setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
    restartButton.addCaptureListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            mEngine.getFirstEntityOfType(GameStateEntity.class).onStartGame();
        }
    });

    // try to correctly position the bottom restart button
    rootTable.add(restartButton)
            .expand(true, false)
            .width(dialogWidth - (dialogMargin * 4.f))
            .height(dialogHeight * 0.08f)
            .padTop(mDefaultMargin * 0.5f)
            .padBottom(mDefaultMargin)
            .padLeft(mDefaultMargin)
            .padRight(mDefaultMargin)
            .center();

    stage.addActor(rootTable);
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:70,代码来源:LeaderBoardGuiEntity.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.TextButton.addCaptureListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。