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


Java Button.setPosition方法代码示例

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


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

示例1: drawdefenders

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void drawdefenders(){
    defenders = new DrawDefenders();
    groupBtnDefender = new Group();
    Button btn1 = new Button(new ImageButton.ImageButtonStyle());
    btn1.setName("btn1");
    btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn1.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn1);
    Button btn2 = new Button(new ImageButton.ImageButtonStyle());
    btn2.setName("btn2");
    btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn2.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f);
    groupBtnDefender.addActor(btn2);
    Button btn3 = new Button(new ImageButton.ImageButtonStyle());
    btn3.setName("btn3");
    btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn3.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn3);
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:20,代码来源:ScreenCombat.java

示例2: drawAttachers

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void drawAttachers(){
    attachers = new DrawAttachers();
    Button btn1 = new Button(new ImageButton.ImageButtonStyle());
    btn1.setName("btn4");
    btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn1.setPosition(Gdx.graphics.getWidth() - btn1.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn1);
    Button btn2 = new Button(new ImageButton.ImageButtonStyle());
    btn2.setName("btn5");
    btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn2.setPosition(Gdx.graphics.getWidth() - btn2.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f);
    groupBtnDefender.addActor(btn2);
    Button btn3 = new Button(new ImageButton.ImageButtonStyle());
    btn3.setName("btn6");
    btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn3.setPosition(Gdx.graphics.getWidth() - btn3.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn3);
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:19,代码来源:ScreenCombat.java

示例3: createMobileMoveButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
private void createMobileMoveButton() {
    float screenWidth = Gdx.graphics.getWidth();
    float screenHeight = Gdx.graphics.getHeight();

    moveButton = new Button(skin);
    moveButton.getStyle().down = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_DOWN_COLOR);
    moveButton.getStyle().up = new TextureRegionDrawable(AssetManager.getInstance().getTextureRegion("default")).tint(MOBILE_BUTTON_UP_COLOR);
    moveButton.setSize(screenWidth * 0.35f, screenHeight * 0.2f);
    moveButton.setPosition(screenWidth / 32, screenHeight / 32f);
    moveButton.addListener(new com.badlogic.gdx.scenes.scene2d.InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            boolean isTutorial = DAO.getInstance().getBoolean(DAO.IS_NEW_KEY, true);
            if (Globals.getGameState() == Game.State.WAIT_FOR_INPUT) {
                Globals.setGameState(Game.State.RUNNING);
            }

            if (Globals.getGameState() == Game.State.RUNNING) {
                movePointer = pointer;
            }
            return true;
        }
    });

    stage.addActor(moveButton);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:27,代码来源:HUD.java

示例4: HexaFrameBottom

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public HexaFrameBottom(Skin hudSkin) {
    super();
    this.hudSkin = hudSkin;
    hexaFrameImage = new Image(hudSkin.getRegion(HEXA_FRAME_NAME));
    setWidth(hexaFrameImage.getWidth());
    setHeight(hexaFrameImage.getHeight());

    frameHiddenButton = new Button(hudSkin, "frame_bottom_hidden");
    frameHiddenButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            hide(false);
        }
    });
    frameHiddenButton.setPosition(0, 0);

    frameVisibleGroup.addActor(hexaFrameImage);
    addActor(frameVisibleGroup);
    addActor(frameHiddenButton);
}
 
开发者ID:RageGo,项目名称:RageGo,代码行数:21,代码来源:HexaFrameBottom.java

示例5: InspectButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public InspectButton(Stage stage) {
	Button button = new Button(Drawables.texture("ui/inspectButtonUp"), Drawables.texture("ui/inspectButtonDown"));
	stage.addActor(button);
	button.setPosition(Config.viewWidth - 68, 20);
	button.addListener(new ClickListener() {
		@Override
		public void clicked(InputEvent event, float x, float y) {
			super.clicked(event, x, y);
			onInteractPressed();
		}

	});

}
 
开发者ID:adketuri,项目名称:umbracraft,代码行数:15,代码来源:InspectButton.java

示例6: MainMenuButton

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public MainMenuButton(Stage stage) {
	Button button = new Button(Drawables.texture("ui/menuButtonUp"), Drawables.texture("ui/menuButtonDown"));
	stage.addActor(button);
	button.setPosition(Config.viewWidth - 40, Config.viewHeight - 40);
	button.addListener(new ClickListener() {
		@Override
		public void clicked(InputEvent event, float x, float y) {
			super.clicked(event, x, y);
			onMenuPressed();
		}

	});
}
 
开发者ID:adketuri,项目名称:umbracraft,代码行数:14,代码来源:MainMenuButton.java

示例7: getMusic

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public Button getMusic(){
    //Music Button
    music = new Button(assets.miscS.getDrawable("music"), assets.miscS.getDrawable("musicOff"),assets.miscS.getDrawable("musicOff"));
    music.setHeight(Gdx.graphics.getHeight() / 17);
    music.setWidth(Gdx.graphics.getWidth() / 13);
    music.setPosition(Gdx.graphics.getWidth() - music.getWidth(), Gdx.graphics.getHeight() - music.getHeight());

    return music;
}
 
开发者ID:msk610,项目名称:3D-TETRIS,代码行数:10,代码来源:ButtonLoader.java

示例8: getSound

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public Button getSound(){
    //Sound Button
    sound = new Button(assets.miscS.getDrawable("sound"), assets.miscS.getDrawable("soundOff"),assets.miscS.getDrawable("soundOff"));
    sound.setHeight(Gdx.graphics.getHeight() / 17);
    sound.setWidth(Gdx.graphics.getWidth() / 13);
    sound.setPosition(Gdx.graphics.getWidth()-music.getWidth()-sound.getWidth()*5/4, Gdx.graphics.getHeight()-sound.getHeight());

    return sound;
}
 
开发者ID:msk610,项目名称:3D-TETRIS,代码行数:10,代码来源:ButtonLoader.java

示例9: show

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
@Override
public void show() {
	// Music
	bgMusic = Gdx.audio.newMusic(Gdx.files.internal("mainmenu/new/bgmusic.mp3"));
	bgMusic.play();
	bgMusic.setLooping(true);

	stage = new Stage(new ScreenViewport());
	Gdx.input.setInputProcessor(stage);

	// Play button
	Image up = new Image(new Texture("mainmenu/new/playbutton1.png"));
	Image down = new Image(new Texture("mainmenu/new/playbutton2.png"));
	Button playbutton = new Button(up.getDrawable(), down.getDrawable());
	playbutton.setPosition(Gdx.graphics.getWidth() / 2 - playbutton.getWidth() / 2, 300);
	playbutton.addListener(new ClickListener() {
		@Override
		public void clicked(InputEvent event, float x, float y) {
			Noeron.changeScreen(new Game(World.generateWorld(new Random().nextLong())));
		}
	});

	// Header
	Image header = new Image(new Texture("mainmenu/noeron.png"));
	header.setPosition(Gdx.graphics.getWidth() / 2 - header.getWidth() / 2, 550);

	// Background
	Image bg = new Image(new Texture("mainmenu/new/bg.png"));

	stage.addActor(bg);
	stage.addActor(header);
	stage.addActor(playbutton);

	Gdx.app.debug("Main Menu", "Finished setting up Scene2D.");
}
 
开发者ID:OxideDevelopment,项目名称:Noeron,代码行数:36,代码来源:MainMenu.java

示例10: create

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
@Override
	public void create () {
		Gdx.app.setLogLevel(Application.LOG_DEBUG);

		//Configurar cámara de libGDX
		camera = new ARCamera(67,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
		camera.position.set(0f,0f,1f);
		camera.lookAt(0,0,0);
		camera.near = 0;
		camera.far = 1000f;
		camera.update();

		/*
		 * CARGAR RECURSOS
		 * LOAD ASSETS
		 */
		manager = new AssetManager();
		manager.load("splash.png", Texture.class);
		manager.load("cam_button_down.png", Texture.class);
		manager.load("cam_button_up.png", Texture.class);
		manager.finishLoading(); //Esperar hasta que carge la imagen de splash - Wait until splash image load
		/* Añade los modelos para ser cargados.
		 * Note que los modelos no se cargan inmediatamente, se cargan utilizando manager.update() en el metodo render
		 * Add the models for loading.
		 * Note that models are not loaded inmediately, they load using manager.update() on render method
		 */
		manager.load("wolf.g3db",Model.class);
		manager.load("koko.g3db",Model.class);
		manager.load("watercraft.g3db",Model.class);
		manager.load("landscape.g3db",Model.class);
//		manager.load("houses.g3db",Model.class);

		batch_3d = new ModelBatch();

		//Adding lights
		environment = new Environment();
		environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
		environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

		//2D
		stage = new Stage(new ScreenViewport());
		splash_img = new Image(manager.get("splash.png",Texture.class));

		/* Create a button to open the camera preferences activity. First we define what images will be rendered when up and down
		 * Crear un botón para abrir la actividad de preferencias de camara. Primero definimos que imagenes mostrar cuando esta arriba y abajo
		 */
		Button.ButtonStyle buttonStyle = new Button.ButtonStyle();
		buttonStyle.up = new Image(manager.get("cam_button_up.png",Texture.class)).getDrawable();
		buttonStyle.down = new Image(manager.get("cam_button_down.png",Texture.class)).getDrawable();
		cameraPrefsButton = new Button(buttonStyle);
		//Damos una posicion en la parte superior derecha de la pantalla
		cameraPrefsButton.setPosition(stage.getWidth() - 20 - cameraPrefsButton.getHeight(),stage.getHeight() - 20 - cameraPrefsButton.getHeight());
		/* Recognize when button is clicked and open camera preferences using arToolKitMangaer
		 * Reconoce cuando el botón se ha presionado y abre preferencias de cámara
		 */
		cameraPrefsButton.addListener(new ClickListener(){
			public void clicked (InputEvent event, float x, float y) {
				arToolKitManager.openCameraPreferences();
			}
		});
		/* Let's add the splash image to the stage to be rendered while assets load on background
		 * Note we didn't add the button to stage, it will be added once the assets are done loading
		 * Añadamos la imagen de presentación (splash) para que se muestre mientras los recursos cargan en segundo plano
		 * Note que no añadimos el boton al stage, eso se hará una vez los recursos hayan sido cargados
		 */
		stage.addActor(splash_img);
		/*
		 * Finalmente como tenemos un boton que se puede presionar, debemos hacer que el stage reciba entradas
		 * Finally as we have a button to be pressed, we need to make stage to receive inputs
		 */
		Gdx.input.setInputProcessor(stage);
	}
 
开发者ID:GLUD,项目名称:trascendentAR,代码行数:73,代码来源:main.java

示例11: generateGameButtons

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
public void generateGameButtons(){
    //Game Buttons
    up = new TextButton("",assets.up);
    down = new TextButton("",assets.down);
    left = new TextButton("",assets.left);
    right = new TextButton("",assets.right);
    a = new TextButton("",assets.a);

    left.setWidth(Gdx.graphics.getWidth() / 7);
    left.setHeight(Gdx.graphics.getHeight() / 7);

    a.setWidth(Gdx.graphics.getWidth() / 7);
    a.setHeight(Gdx.graphics.getHeight() / 7);

    up.setWidth(Gdx.graphics.getWidth() / 7);
    up.setHeight(Gdx.graphics.getHeight() / 6);
    up.setPosition(left.getWidth() / 2 + a.getWidth() / 6, up.getHeight() + up.getHeight() / 2 + a.getHeight() / 6);

    right.setWidth(Gdx.graphics.getWidth() / 8);
    right.setHeight(Gdx.graphics.getHeight() / 7);
    right.setPosition(a.getWidth() + a.getWidth() / 4 + a.getHeight() / 6 + a.getWidth() / 6, left.getHeight() - left.getHeight() / 4 + a.getWidth() / 10);

    left.setPosition(-20, left.getHeight() - left.getHeight() / 4 + a.getWidth() / 9);
    down.setWidth(Gdx.graphics.getWidth() / 7);
    down.setHeight(Gdx.graphics.getHeight() / 6);
    down.setPosition(left.getWidth() / 2 + a.getWidth() / 6, 0 - down.getHeight() / 8);

    rx = new TextButton("",assets.rx);
    ry = new TextButton("",assets.ry);
    rz = new TextButton("",assets.rz);

    rz.setWidth(Gdx.graphics.getWidth() / 7);
    rz.setHeight(Gdx.graphics.getHeight() / 7 + 2f);
    rz.setPosition(Gdx.graphics.getWidth() - rz.getWidth() + 2f, 0 + rz.getHeight() / 2+10f);

    ry.setHeight(Gdx.graphics.getHeight() / 7 + 2f);
    ry.setWidth(Gdx.graphics.getWidth() / 7);
    ry.setPosition(Gdx.graphics.getWidth() - rz.getWidth() - ry.getWidth() + 2f, 0 + ry.getHeight() / 2+10f);

    rx.setHeight(Gdx.graphics.getHeight() / 7 + 2f);
    rx.setWidth(Gdx.graphics.getWidth() / 7);
    rx.setPosition(Gdx.graphics.getWidth() - rz.getWidth() - ry.getWidth() - rx.getWidth(), 0 + ry.getHeight() / 2+10f);

    play = new Button(assets.miscS.getDrawable("pause"),assets.miscS.getDrawable("play"),assets.miscS.getDrawable("play"));
    play.setHeight(Gdx.graphics.getHeight() / 8);
    play.setWidth(Gdx.graphics.getWidth() / 8);
    play.setPosition(0, Gdx.graphics.getHeight() - play.getHeight());

    clock = new Button(assets.other.getDrawable("c"), assets.other.getDrawable("cc"), assets.other.getDrawable("cc"));
    clock.setWidth(Gdx.graphics.getWidth() / 8);
    clock.setHeight(Gdx.graphics.getHeight() / 8);
    clock.setPosition(Gdx.graphics.getWidth() - rz.getWidth() - ry.getWidth(), rz.getHeight() + rz.getHeight() / 2);
    a.setPosition(Gdx.graphics.getWidth() - rz.getWidth() - ry.getWidth(), -10);

    cameraB = new TextButton("camera",assets.smallStyle);
    cameraB.setHeight(Gdx.graphics.getWidth() / 4);
    cameraB.setWidth(Gdx.graphics.getWidth() / 3);
    cameraB.setPosition(-40, Gdx.graphics.getHeight() - 2 * play.getHeight() - cameraB.getHeight() / 2 - play.getHeight());

    quit = new TextButton("QUIT",assets.smallStyle);
    quit.setWidth(Gdx.graphics.getWidth() / 4);
    quit.setHeight(Gdx.graphics.getWidth() / 4);
    quit.setPosition(Gdx.graphics.getWidth()/2+quit.getWidth()/2,Gdx.graphics.getHeight() - play.getHeight()*3);
}
 
开发者ID:msk610,项目名称:3D-TETRIS,代码行数:65,代码来源:ButtonLoader.java

示例12: initialize

import com.badlogic.gdx.scenes.scene2d.ui.Button; //导入方法依赖的package包/类
@Override
	protected void initialize() {
		fontTexture = new Texture(
				Gdx.files.internal("fonts/ConsolaMono-Bold.png"));
		fontTexture.setFilter(TextureFilter.Linear,
				TextureFilter.MipMapLinearLinear);
		TextureRegion fontRegion = new TextureRegion(fontTexture);
//		font = new BitmapFont(Gdx.files.internal("fonts/ConsolaMono-Bold.fnt"),
//				fontRegion, false);
		font = FontManager.getFontHalf();
		scoreFont = new BitmapFont(Gdx.files.internal("fonts/ConsolaMono-Bold.fnt"),
				fontRegion, false);
		
		pixel = SpriteManager.getSprite("pixel");
		pauseButtonAtlas = SpriteManager.getSprite("pause");
		pauseButtonPressedAtlas = SpriteManager.getSprite("pause-pressed");
		menuButtonAtlas = SpriteManager.getSprite("pause-menu-button");
		menuButtonPressedAtlas = SpriteManager.getSprite("pause-menu-button-pressed");
        
        stage.setViewport(Constants.FRAME_WIDTH, Constants.FRAME_HEIGHT, true);
        
        TextButtonStyle style = new TextButtonStyle();
        style.up = new TextureRegionDrawable(pauseButtonAtlas);
        style.down = new TextureRegionDrawable(pauseButtonPressedAtlas);
        style.font = font;
        style.fontColor = new Color(1, 0, 0, 1);
        pauseButton = new Button(style);
        pauseButton.setSize(30, 30);
        pauseButton.setPosition(15, 10);
		pauseButton.addListener(new InputListener() {
			@Override
			public boolean touchDown(InputEvent event, float x, float y,
					int pointer, int button) {
				gameController.pause();
				return true;
			}
		});
        stage.addActor(pauseButton);
        
        totalScoreLabelStyle = new LabelStyle();
        totalScoreGroup = new Group();
        font.setScale(0.5f);
        totalScoreLabelStyle.font = font;
        totalScore = new Label("Score: 0", totalScoreLabelStyle);
        totalScore.setScale(0.1f);
        totalScore.setPosition(totalScoreX, totalScoreY);
        totalScoreGroup.addActor(totalScore);
        stage.addActor(totalScoreGroup);
        
        scoreLabelStyle = new LabelStyle();
        scoreLabelStyle.font = scoreFont;
        scoreGroup = new Group();
        score = new Label("", scoreLabelStyle);
        score.setPosition(scoreX, scoreY);
        scoreGroup.addActor(score);
        stage.addActor(scoreGroup);
        
        stage.addActor(new EnergyBarActor());
        
        animationAction = new MoveToAction();
        animationAction.setPosition(totalScoreX, totalScoreY + 50);
        animationAction.setDuration(0.5f);
        
        currentScoreState = TextState.HIDDEN;
        
        pauseMenu = new PauseMenu();
        stage.addActor(pauseMenu);
        pauseMenu.setVisible(false);
        
        gameOverMenu = new GameOverMenu();
        stage.addActor(gameOverMenu);
        gameOverMenu.setVisible(false);
	}
 
开发者ID:matachi,项目名称:skuttande-nyan-cat,代码行数:74,代码来源:HudRenderSystem.java


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