當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。