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


Java ImageButton.addListener方法代码示例

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


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

示例1: initButtons

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public void initButtons(int score,TextureAtlas buttonAtlas) {
    Skin buttonSkin = new Skin();
    buttonSkin.addRegions(buttonAtlas);

    //TODO FIX THIS SHIT INDENTATION
    //TODO Long-term fix the magic numbers
    ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
    		                                                        buttonSkin.getDrawable("playbutton"));
    playButton.setSize(256, 64);
    playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
    		               screenSize.height/2-playButton.getHeight()/2+50);
    playButton.addListener(new InputListener() {

    	@Override
    	public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    		polymorph.setScreen(new GameScreen(polymorph));
    		DeathScreenMusic.stop();
    		return true;
    	}
    });

    stage.addActor(playButton);

}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:25,代码来源:DeathScreen.java

示例2: MenuScreen

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public MenuScreen(final LePendu game) {
    super(game);

    titleImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("title")));
    playBtn  = new ImageButton(new TextureRegionDrawable(game.atlas.findRegion("playBtn")));
    decosImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("decos")));

    table.add(titleImg).top().padTop(169);
    table.row();
    table.add(playBtn).expandY();
    table.row();
    table.add(decosImg).bottom().padBottom(50);

    playBtn.addListener(new ChangeListener() {
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            game.setScreen(new DifficultyScreen(game));
        }
    });
}
 
开发者ID:Frappagames,项目名称:le-pendu,代码行数:20,代码来源:MenuScreen.java

示例3: KeyboardActor

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public KeyboardActor(final PlayScreen playScreen) {
    alphabet = new Texture("alphabet.png");

    for (int i = 0 ; i < 26 ; i++) {
        if (i%7 == 0) {
            hg  = new HorizontalGroup();
            this.addActor(hg);
        }
        final char character = (char) (i + 65);

        button = new ImageButton(new TextureRegionDrawable(new TextureRegion(alphabet, i * 90, 0, 90, 90)));
        button.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                playScreen.proposeLetter(character);
            }
        });

        hg.addActor(button);
    }
}
 
开发者ID:Frappagames,项目名称:le-pendu,代码行数:22,代码来源:KeyboardActor.java

示例4: HelpButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public HelpButton(final Application app, final MenuHud menuHud, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("help-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("help-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            menuHud.removeAllActorsFromStage();
            ColorOverlay.enabled = false;
            app.setScreen(new HelpScreen(app, atlas));
        }
    });
}
 
开发者ID:NahroTo,项目名称:Teleport-Ball,代码行数:20,代码来源:HelpButton.java

示例5: PlayButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public PlayButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("pb-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("pb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);
    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            app.setScreen(new GameScreen(app, atlas));
        }
    });
}
 
开发者ID:NahroTo,项目名称:Teleport-Ball,代码行数:17,代码来源:PlayButton.java

示例6: HomeButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public HomeButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("home-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("home-down"));

    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            app.setScreen(new MenuScreen(app));
        }
    });
}
 
开发者ID:NahroTo,项目名称:Teleport-Ball,代码行数:21,代码来源:HomeButton.java

示例7: RestartButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public RestartButton(final Player player, final Ball ball, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("rb-normal"));
    drawableDown = new SpriteDrawable(atlas.createSprite("rb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            ball.reset();
            player.reset();
        }
    });
}
 
开发者ID:NahroTo,项目名称:Teleport-Ball,代码行数:21,代码来源:RestartButton.java

示例8: GameSpeedController

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public GameSpeedController(TextureAtlas buttonAtlas) {
	btnPauseStyle = new ImageButton.ImageButtonStyle();
	btnPauseStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("pause-up"));
	btnPauseStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("pause-down"));

	btnPlayStyle = new ImageButton.ImageButtonStyle();
	btnPlayStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("play-up"));
	btnPlayStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("play-down"));

	btnSlowStyle = new ImageButton.ImageButtonStyle();
	btnSlowStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("slow-up"));
	btnSlowStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("slow-down"));

	imageButton = new ImageButton(btnPauseStyle);

	add(imageButton);

	imageButton.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			setGameSpeed();
			event.cancel();
		}
	});
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:26,代码来源:GameSpeedController.java

示例9: FormationPatternTable

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public FormationPatternTable (final Entity squad, Skin skin) {
	this.skin = skin;
	buttonGroup = new ButtonGroup<ImageButton>();
	buttonGroup.setMaxCheckCount(1);
	buttonGroup.setMinCheckCount(1);

	for(int i = 0; i < FormationPatternType.values().length; i++){
		final ImageButton button = createFormationButton(FormationPatternType.values()[i], skin);
		button.addListener(new ChangeListener() {
		
			@Override
			public void changed (ChangeEvent event, Actor actor) {
				if(button.isChecked()){
					Components.SQUAD.get(squad).setFormationPattern((FormationPatternType) button.getUserObject());
				}
				
			}
		});
		
		add(button);
		buttonGroup.add(button);
	}
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:24,代码来源:FormationPatternTable.java

示例10: GamesOpenActor

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public GamesOpenActor(Skin skin) {
	super(skin);
	
	games = new GamesOpen();
	gamesWindow = new ScrollWindow("Spiele", skin, games.getGamesTable());
	ImageButton backButton = new ImageButton(skin, "imageButtonBack");
	
	setFillParent(true);
	
	add(gamesWindow).width(800).height(TeacherMain.HEIGHT - 16).expand().left().pad(8);
	add(backButton).width(135).height(125).getTable().pad(16);
	
	backButton.addListener(new ChangeListener() {
		public void changed (ChangeEvent event, Actor actor) {
			AppMain.setNewScreen(AppMain.loginScreen);
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:19,代码来源:GamesOpenActor.java

示例11: TeacherGamesScreen

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public TeacherGamesScreen(Viewport viewport, SpriteBatch batch) {
	super(viewport, batch);
	
	TextureRegion backgroundTexture = new TextureRegion(Resources.assets.get("background.png", Texture.class));
	Skin skin = Resources.skin;
	
	background = new Background(backgroundTexture);
	gamesActor = new GamesActor(skin);
	changeToLoginRegisterButton = new ImageButton(skin, "imageButtonBack");
	reconnectButton = Resources.reconnectButton;
	
	stage.addActor(background);
	stage.addActor(gamesActor);
	stage.addActor(changeToLoginRegisterButton);
	
	changeToLoginRegisterButton.setBounds(AppMain.WIDTH - 102, AppMain.HEIGHT - 102, 100, 100);
	
	changeToLoginRegisterButton.addListener(new ClickListener() {

		@Override 
		public void clicked(InputEvent event, float x, float y){
			TeacherMain.setNewScreen(TeacherMain.teacherLoginRegisterScreen);
		}
	});
}
 
开发者ID:javosuher,项目名称:Terminkalender,代码行数:26,代码来源:TeacherGamesScreen.java

示例12: createSwitchScreenButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
public Button createSwitchScreenButton(
        Sprite text,
        Sprite up,
        Sprite down,
        final AbstractScreen<TaflGame> parent,
        final AbstractScreen<TaflGame> screen) {

    ImageButton button = new ImageButton(new DoubleTextureDrawable(new TextureRegion(up), new TextureRegion(text)),
            new DoubleTextureDrawable(new TextureRegion(down), new TextureRegion(text)));

    button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            soundService.playSound(Assets.Sounds.CLICK_SOUND);
            parent.switchScreen(screen);
        }
    });

    return button;
}
 
开发者ID:apotapov,项目名称:tafl,代码行数:21,代码来源:TaflGame.java

示例13: initControls

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
private void initControls() {
    TextureRegion textureRegion = new TextureRegion(
            game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.CLOSE));

    TextureRegionDrawable imageUp = new TextureRegionDrawable(textureRegion);
    imageUp.setMinWidth(game.deviceSettings.menuButtonHeight / 2);
    imageUp.setMinHeight(game.deviceSettings.menuButtonHeight / 2);

    closeButton = new ImageButton(imageUp);
    closeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.soundService.playSound(Assets.Sounds.CLICK_SOUND);
            back();
        }
    });

    Table controls = new Table();
    controls.setFillParent(true);
    controls.add(closeButton).expand().bottom().right().pad(
            game.deviceSettings.menuSpacing).size(game.deviceSettings.menuButtonHeight);
    stage.addActor(controls);
}
 
开发者ID:apotapov,项目名称:tafl,代码行数:26,代码来源:InstructionScreen.java

示例14: initControls

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
private void initControls() {
    TextureRegion textureRegion = new TextureRegion(
            game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.CLOSE));

    TextureRegionDrawable imageUp = new TextureRegionDrawable(textureRegion);
    imageUp.setMinWidth(game.deviceSettings.menuButtonHeight / 2);
    imageUp.setMinHeight(game.deviceSettings.menuButtonHeight / 2);

    ImageButton closeButton = new ImageButton(imageUp);
    closeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.soundService.playSound(Assets.Sounds.CLICK_SOUND);
            back();
        }
    });

    Table controls = new Table();
    controls.setFillParent(true);
    controls.add(closeButton).expand().bottom().right().pad(
            game.deviceSettings.menuSpacing).size(game.deviceSettings.menuButtonHeight);
    stage.addActor(controls);
}
 
开发者ID:apotapov,项目名称:tafl,代码行数:26,代码来源:AboutScreen.java

示例15: createUndo

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //导入方法依赖的package包/类
private static void createUndo(HudRenderingComponent component,
        Skin skin, Table table, TaflWorld gameWorld) {

    final World world = gameWorld.world;

    TextureRegion textureRegion = new TextureRegion(
            gameWorld.game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.UNDO));
    Drawable imageUp = new TextureRegionDrawable(textureRegion);
    ImageButton button = new ImageButton(imageUp);

    button.addListener(new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            UndoEvent undoEvent = SystemEvent.createEvent(UndoEvent.class);
            world.postEvent(null, undoEvent);
        }
    });
    table.add(button).size(gameWorld.game.deviceSettings.hudButtonHeight).expandX();
}
 
开发者ID:apotapov,项目名称:tafl,代码行数:21,代码来源:HudFactory.java


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