Example usage for com.badlogic.gdx.utils.viewport ExtendViewport ExtendViewport

List of usage examples for com.badlogic.gdx.utils.viewport ExtendViewport ExtendViewport

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils.viewport ExtendViewport ExtendViewport.

Prototype

public ExtendViewport(float minWorldWidth, float minWorldHeight, Camera camera) 

Source Link

Document

Creates a new viewport with no maximum world size.

Usage

From source file:com.dongbat.game.util.CameraUtil.java

public static void init() {
    camera = new OrthographicCamera();
    viewport = new ExtendViewport(MIN_WIDTH, MIN_HEIGHT, camera);
    viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}

From source file:io.piotrjastrzebski.dungen.BaseScreen.java

License:Apache License

public BaseScreen() {
    gameCamera = new OrthographicCamera();
    gameViewport = new ExtendViewport(DungenGame.VP_WIDTH, DungenGame.VP_HEIGHT, gameCamera);
    guiCamera = new OrthographicCamera();
    guiViewport = new ScreenViewport(guiCamera);

    batch = new SpriteBatch();
    renderer = new ShapeRenderer();

    stage = new Stage(guiViewport, batch);
    stage.setDebugAll(debugStage);//from   ww  w .  ja  v a2  s  .c  om
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);
    Gdx.input.setInputProcessor(multiplexer = new InputMultiplexer(stage, this));

    Gdx.app.log(TAG, "F1 - toggle stage debug");
}

From source file:headmade.arttag.screens.AbstractGameScreen.java

License:Apache License

public AbstractGameScreen(DirectedGame game) {
    this.game = game;
    if (camera == null) {
        camera = new OrthographicCamera();
    }/*w w w  . ja  v  a  2 s.  c o  m*/
    if (viewport == null) {
        viewport = new ExtendViewport(TARGET_SCREEN_WIDTH, TARGET_SCREEN_HEIGHT, camera);
    }
    viewport.apply();
    Gdx.input.setCatchBackKey(false); // will be set to true only when the
    // child override the InputAdapter
    // class methods
}

From source file:com.hindelid.ld.thirtyfour.HUDDisplay.java

License:Apache License

public HUDDisplay() {
    mShapeRenderer = new ShapeRenderer();
    mBatch = new SpriteBatch();
    mFont = new BitmapFont();

    mFont.setColor(Color.RED);//from  w  w  w.j  ava2 s  .c  o  m

    mHUDCamera = new OrthographicCamera();
    mHUDCamera.position.set(400 / 2, 400 / 2, 0);
    mHUDCamera.update();
    mHUDViewport = new ExtendViewport(400, 400, mHUDCamera);
    reset();
}

From source file:io.piotrjastrzebski.sfg.game.objects.Background.java

License:Open Source License

public Background() {
    camera = new ParallaxCamera(GameScreen.VIEWPORT_WIDTH, GameScreen.VIEWPORT_HEIGHT);
    viewPort = new ExtendViewport(GameScreen.VIEWPORT_WIDTH, GameScreen.VIEWPORT_HEIGHT, camera);
    camera.position.set(10, 16, 0);//w  w  w  . j  av a  2  s .  c o  m
    camera.update();
    stars = new Array<Background.Star>();

    final Assets assets = Locator.getAssets();
    bg_back = assets.getRegion("background_back");
    bg_mid = assets.getRegion("background_mid");
    mid_width = bg_mid.getRegionWidth() * GameScreen.BOX2D_TO_PIXEL;
    mid_height = bg_mid.getRegionHeight() * GameScreen.BOX2D_TO_PIXEL;

    bg_front = assets.getRegion("background_front");

    front_width = bg_front.getRegionWidth() * GameScreen.BOX2D_TO_PIXEL;
    front_height = bg_front.getRegionHeight() * GameScreen.BOX2D_TO_PIXEL;

    moon = assets.getScaledSprite("moon");

    for (int i = 0; i < NUM_STARS; i++) {
        stars.add(new Star(assets, width, height));
    }
    offset = 0;
}

From source file:com.hindelid.ld.thirtyfour.Main.java

License:Apache License

@Override
public void create() {
    mShapeRenderer = new ShapeRenderer();
    mHUDDisplay = new HUDDisplay();
    mCamera = new OrthographicCamera();
    mViewPort = new ExtendViewport(Constants.VIEW_SIZE_X, Constants.VIEW_SIZE_Y, mCamera);
    mCurrentViewCord = new Vector2(Constants.VIEW_SIZE_X / 2, Constants.VIEW_SIZE_Y / 2);
    moveAndUpdateCamera();// www .j  a  va2s .  c  o m
    mStartSound = Gdx.audio.newSound(Gdx.files.internal("start.wav"));
    mDeadSound = Gdx.audio.newSound(Gdx.files.internal("dead.wav"));
    mOctoSound = Gdx.audio.newSound(Gdx.files.internal("octo.wav"));
    mFishSound = Gdx.audio.newSound(Gdx.files.internal("fish.wav"));
    resetGame();
}

From source file:com.redtoorange.game.ui.missionui.GunUI.java

License:Open Source License

/** Initialize all of the UI elements. */
private void init() {
    uiCamera = new OrthographicCamera(Global.WINDOW_WIDTH, Global.WINDOW_HEIGHT);
    uiViewport = new ExtendViewport(Global.WINDOW_WIDTH, Global.WINDOW_HEIGHT, uiCamera);

    uiStage = new Stage(uiViewport);
    rootTable = new Table(VisUI.getSkin());
    uiStage.addActor(rootTable);/*  www.  j a v a 2  s. c  om*/
    rootTable.setFillParent(true);

    ammoLabel = new Label("0", VisUI.getSkin());
    ammoLabel.setSize(100f, 100f);
    rootTable.add(ammoLabel).right().bottom().size(100f, 100f).expand();
    currentImage = new Image(regionDrawable);
    rootTable.add(currentImage).bottom().right().size(200, 200);
}

From source file:nl.littlebluefrog.ld34.LD34.java

License:Apache License

@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_INFO);

    tiledCam = new OrthographicCamera();
    int worldWidth = Gdx.graphics.getWidth();
    int worldHeight = Gdx.graphics.getHeight();
    Gdx.app.debug(TAG, "world size = " + worldWidth + "x" + worldHeight);

    hudCam = new OrthographicCamera();
    hudCam.setToOrtho(false, worldWidth, worldHeight);
    mStage = new Stage(new ExtendViewport(worldWidth, worldHeight, hudCam));

    mGameOver = new GameOver();
    mGameOver.setPosition(worldWidth / 2 - 150, worldHeight / 2 - 100);
    mGameOver.setVisible(false);/*from  w w w .j  a  v a  2s  . c  om*/

    mBattleReport = new BattleReport();
    mBattleReport.setPosition(worldWidth / 2 - 150, worldHeight / 2 - 100);
    mBattleReport.setVisible(false);

    mRewardReport = new RewardReport();
    mRewardReport.setPosition(0, 0);
    mRewardReport.setVisible(false);

    mGamelogic = new GameLogicController(this);
    mGamelogic.newGame();

    mPlayer = new Player(mGamelogic);
    mPlayer.setPosition(tiledCam.viewportWidth / 2, tiledCam.viewportHeight / 2 - TILE_WIDTH * 2);

    mPlayerStats = new PlayerStats(mGamelogic);
    mPlayerStats.setPosition(new Vector2(0, worldHeight));

    mStepStats = new StepStats(mGamelogic);
    mStepStats.setPosition(0, worldHeight - 168);

    Button buttonLeft = mGamelogic.getLeftButton();
    buttonLeft.setPosition(mPlayer.getX() - (TILE_WIDTH * 2) - 8, mPlayer.getY() - (TILE_WIDTH * 1.5f));

    Button buttonRight = mGamelogic.getRightButton();
    buttonRight.setPosition(mPlayer.getX() + (TILE_WIDTH * 2) - 8, mPlayer.getY() - (TILE_WIDTH * 1.5f));

    mStage.addActor(mRewardReport);
    mStage.addActor(mPlayer);
    mStage.addActor(mBattleReport);
    mStage.addActor(mPlayerStats);
    mStage.addActor(mStepStats);
    mStage.addActor(buttonLeft);
    mStage.addActor(buttonRight);
    mStage.addActor(mGameOver);

    mInputHandler = new InputHandler(mGamelogic, mStage);
    mStage.act();
}

From source file:com.redtoorange.game.ui.missionui.HealthUI.java

License:Open Source License

/** Build all the UI elements. */
private void buildUIElements() {
    uiCamera = new OrthographicCamera(Global.WINDOW_WIDTH, Global.WINDOW_HEIGHT);
    uiViewport = new ExtendViewport(Global.WINDOW_WIDTH, Global.WINDOW_HEIGHT, uiCamera);

    //Build the table.
    uiStage = new Stage(uiViewport);
    rootTable = new Table(VisUI.getSkin());
    uiStage.addActor(rootTable);//from   ww  w.ja  v  a2 s .c  om
    rootTable.setFillParent(true);
    rootTable.left().top();

    //Fill up the healthMeter is images to be used as healthBars.
    for (int i = 0; i < 20; i++) {
        healthMeter.add(new Image(healthBars.findRegion("highHealth")));
    }
}

From source file:com.badlogic.gdx.tests.ViewportTest1.java

License:Apache License

static public Array<Viewport> getViewports(Camera camera) {
    int minWorldWidth = 640;
    int minWorldHeight = 480;
    int maxWorldWidth = 800;
    int maxWorldHeight = 480;

    Array<Viewport> viewports = new Array();
    viewports.add(new StretchViewport(minWorldWidth, minWorldHeight, camera));
    viewports.add(new FillViewport(minWorldWidth, minWorldHeight, camera));
    viewports.add(new FitViewport(minWorldWidth, minWorldHeight, camera));
    viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, camera));
    viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, maxWorldWidth, maxWorldHeight, camera));
    viewports.add(new ScreenViewport(camera));

    ScreenViewport screenViewport = new ScreenViewport(camera);
    screenViewport.setUnitsPerPixel(0.75f);
    viewports.add(screenViewport);//w w  w  .  java2  s . c  o m

    viewports.add(new ScalingViewport(Scaling.none, minWorldWidth, minWorldHeight, camera));
    return viewports;
}