List of usage examples for com.badlogic.gdx.utils.viewport FitViewport FitViewport
public FitViewport(float worldWidth, float worldHeight, Camera camera)
From source file:com.bss.game.HelpScreen5.java
License:Apache License
public HelpScreen5(MadFishing game) { this.game = game; guiCam = new OrthographicCamera(480, 800); guiCam.position.set(480 / 2, 800 / 2, 0); scaleVP = new FitViewport(480, 800, guiCam); nextBounds = new Rectangle(480 - 150, 100, 150, 100); touchPoint = new Vector3(); helpImage = Assets.loadTexture("help5.png"); helpRegion = new TextureRegion(helpImage, 0, 0, 480, 800); }
From source file:th.skyousuke.libgdx.xomaisad.GameScreen.java
License:Apache License
public GameScreen(final XOMaiSad game, int playerMark) { this.game = game; camera = new OrthographicCamera(); viewport = new FitViewport(XOMaiSad.SCREEN_WIDTH, XOMaiSad.SCREEN_HEIGHT, camera); touchPos = new Vector3(); board = new Board(playerMark); ai = new Ai(); game.glyphLayout.setText(Assets.instance.font, AI_TEXT); aiTextWidth = game.glyphLayout.width; }
From source file:com.bss.game.MainMenuScreen.java
License:Apache License
public MainMenuScreen(MadFishing game) { this.game = game; guiCam = new OrthographicCamera(480, 800); guiCam.position.set(480 / 2, 800 / 2, 0); fitVP = new FitViewport(480, 800, guiCam); soundBounds = new Rectangle(240 - 32, 550, 64, 64); playBounds = new Rectangle(10, 400, 460, 100); highscoresBounds = new Rectangle(10, 250, 460, 100); helpBounds = new Rectangle(10, 100, 460, 100); touchPoint = new Vector3(); }
From source file:ch.coldpixel.mario.Scenes.Hud.java
public Hud(SpriteBatch sb) { worldTimer = 300;//from w ww . ja v a 2 s .c om timeCount = 0; score = 0; viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera()); stage = new Stage(viewport, sb); Table table = new Table(); table.top(); //Top of our Stage table.setFillParent(true); //Table = size of our stage countdownLabel = new Label(String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));//%03d = how many numbers, d=int,BitmapFont = Graphic Font, not regular Font scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); table.add(marioLabel).expandX().padTop(10); //expandX = shares width with all elements, ex: 3 elements, each takes 1/3 table.add(worldLabel).expandX().padTop(10); table.add(timeLabel).expandX().padTop(10); table.row();//New row table.add(scoreLabel).expandX(); table.add(levelLabel).expandX(); table.add(countdownLabel).expandX(); stage.addActor(table);//Add table to Stage }
From source file:com.oceangamejam.game.Scenes.Hud.java
public Hud(SpriteBatch sb, Camera ocam) { worldTimer = 10;/*from w ww. j a va 2s . co m*/ timeCount = 0; score = 0; map = new OrthographicCamera(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2); viewPort = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new OrthographicCamera()); stage = new Stage(viewPort, sb); Table table = new Table(); table.top(); table.setFillParent(true); font = new BitmapFont(); font.getData().setScale(2.5f, 2.5f); countdownLabel = new Label(String.format("%02d:%02d", worldTimer / 60, worldTimer % 60), new Label.LabelStyle(font, Color.WHITE)); scoreLabel = new Label(String.format("%03d", score), new Label.LabelStyle(font, Color.WHITE)); timeLabel = new Label("TIME", new Label.LabelStyle(font, Color.WHITE)); fishLabel = new Label("CAUGHT FISHES", new Label.LabelStyle(font, Color.WHITE)); table.add(fishLabel).expandX().padTop(10); table.add(timeLabel).expandX().padTop(10); table.row(); table.add(scoreLabel).expandX(); table.add(countdownLabel).expandX(); stage.addActor(table); }
From source file:com.bss.game.HighscoresScreen.java
License:Apache License
public HighscoresScreen(MadFishing game) { this.game = game; guiCam = new OrthographicCamera(480f, 800f); guiCam.position.set(480f / 2f, 800f / 2f, 0); fitVP = new FitViewport(480f, 800f, guiCam); backBounds = new Rectangle(0, 100f, 150f, 75f); touchPoint = new Vector3(); highScores = "" + Assets.getHighScore(); }
From source file:com.roterballon.balloonburster.scenes.AboutHUD.java
License:Common Public License
public AboutHUD(com.roterballon.balloonburster.BalloonBursterGame game) { this.game = game; this.assetmanager = game.getAssetManager(); this.skin = new Skin(Gdx.files.internal("skin/uiskin.json")); this.viewport = new FitViewport(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH, com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT, new OrthographicCamera()); this.stage = new Stage(this.viewport, game.getSpriteBatch()); // create wrapper table Table wrapper = new Table(); wrapper.top();/*from w w w .j av a 2 s. c om*/ wrapper.setWidth(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH * 0.8f); wrapper.setHeight(com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT * 0.65f); Label aboutLabel = new Label("About", skin, "logo"); wrapper.add(aboutLabel).expandX().align(Align.left); wrapper.row(); // create scroll wrapper table Table scrollWrapper = new Table(); //scrollWrapper.debug(); scrollWrapper.top(); // create content for scrollWrapper Label graphicsLabel = new Label("Graphics", skin, "bold"); scrollWrapper.add(graphicsLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //cloud 1 attribution Label cloud1LinkLabel = new Label("Clouds", skin, "link"); cloud1LinkLabel.setAlignment(Align.center); cloud1LinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.flickr.com/photos/craightonmiller/5944377614/"); } }); scrollWrapper.add(cloud1LinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String cloud1Text = "by Craighton Miller is licensed under CC BY 2.0"; Label cloud1TextLabel = new Label(cloud1Text, skin); cloud1TextLabel.setWrap(true); scrollWrapper.add(cloud1TextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //cloud 2 attribution Label cloud2LinkLabel = new Label("Single white cloud on a clear blue sky", skin, "link"); cloud2LinkLabel.setWrap(true); cloud2LinkLabel.setAlignment(Align.center); cloud2LinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.flickr.com/photos/horiavarlan/4777129318"); } }); scrollWrapper.add(cloud2LinkLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); String cloud2Text = "by Horia Varlan is licensed under CC BY 2.0"; Label cloud2TextLabel = new Label(cloud2Text, skin); cloud2TextLabel.setWrap(true); scrollWrapper.add(cloud2TextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //balloons attribution Label balloonsTextLabel = new Label("Balloons created by", skin); balloonsTextLabel.setWrap(true); balloonsTextLabel.setAlignment(Align.center); scrollWrapper.add(balloonsTextLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); Label balloonsLinkLabel = new Label("Marius Nolden", skin, "link"); balloonsLinkLabel.setAlignment(Align.center); balloonsLinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.youtube.com/user/HydriasLP"); } }); scrollWrapper.add(balloonsLinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //sound attribution Label soundLabel = new Label("Sound", skin, "bold"); scrollWrapper.add(soundLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); //music attribution Label musicLinkLabel = new Label("Flight", skin, "link"); musicLinkLabel.setAlignment(Align.center); musicLinkLabel.addListener(new ClickListener() { public void clicked(InputEvent e, float x, float y) { Gdx.net.openURI("https://soundcloud.com/iamhydra/flight"); } }); scrollWrapper.add(musicLinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String musicText = "by Hydra and LucienMusique is used as background music."; Label musicTextLabel = new Label(musicText, skin); musicTextLabel.setWrap(true); scrollWrapper.add(musicTextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //balloon pop attribution Label balloonPopLinkLabel = new Label("Balloon Pop", skin, "link"); balloonPopLinkLabel.setAlignment(Align.center); balloonPopLinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("http://www.freesound.org/people/qubodup/sounds/222373/"); } }); scrollWrapper.add(balloonPopLinkLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); String balloonPopText = "by qubodup is licensed under CC BY 3.0"; Label balloonPopTextLabel = new Label(balloonPopText, skin); balloonPopTextLabel.setWrap(true); scrollWrapper.add(balloonPopTextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String dev = "A game developed by roterballon.com"; Label devLabel = new Label(dev, skin, "bold-outline"); devLabel.setWrap(true); devLabel.setAlignment(Align.center); scrollWrapper.add(devLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.pack(); // create scroll pane ScrollPane scrollContainer = new ScrollPane(scrollWrapper); scrollContainer.setOverscroll(false, true); wrapper.add(scrollContainer).expandX().align(Align.left); // set Background wrapper.setBackground(new NinePatchDrawable( new NinePatch(assetmanager.get("img/bg_ninepatch.png", Texture.class), 10, 10, 10, 10))); wrapper.pack(); wrapper.setWidth(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH * 0.8f); wrapper.setHeight(com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT * 0.65f); wrapper.setPosition(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH / 2, com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT - wrapper.getHeight() / 2 - 220, Align.center); // padTop of 220 ImageButton menu = new ImageButton( new TextureRegionDrawable( assetmanager.get("img/buttons/buttons.atlas", TextureAtlas.class).findRegion("btn_menu")), new TextureRegionDrawable(assetmanager.get("img/buttons/buttons.atlas", TextureAtlas.class) .findRegion("btn_menu_pressed"))); menu.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { AboutHUD.this.game.transition(new MenuScreen(AboutHUD.this.game)); } }); menu.setSize(400, 70); menu.setPosition(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH / 2, wrapper.getY() - 50, Align.top | Align.center); stage.addActor(wrapper); stage.addActor(menu); Gdx.input.setInputProcessor(stage); }
From source file:uk.josephmansfield.interplanar.graphics.SceneRenderer.java
License:Open Source License
@Override public void resize(int width, int height) { this.width = width; this.height = height; if (viewport == null) { viewport = new FitViewport(width, height, camera); }/* w w w . jav a 2 s.c o m*/ }
From source file:com.mygdx.game.LoadingGameScreen.java
License:Apache License
@Override public void show() { camera = new OrthographicCamera(); camera.position.set(GdxDemo3D.WIDTH * .5f, GdxDemo3D.HEIGHT * .5f, 0); camera.update();/*from w ww.j a v a 2 s .c o m*/ viewport = new FitViewport(GdxDemo3D.WIDTH, GdxDemo3D.HEIGHT, camera); shapeRenderer = new ShapeRenderer(); }
From source file:javagdxdungeon.MainListener.java
@Override public void create() { System.out.println("create");//?? camera = new OrthographicCamera(VViewLength, HViewLength); camera.setToOrtho(false, VViewLength, HViewLength); viewport = new FitViewport(VViewLength, HViewLength, camera); camera.position.y = 80;/* w w w. j a va 2 s. c o m*/ shapeRenderer = new ShapeRenderer(); terraincreate = new TerrainCreate(); font = new BitmapFont(); FileHandle fh = Gdx.files.internal("atlas/colorfulman.txt"); atlas = new TextureAtlas(fh); count = 0; texture = new Texture("graph/Tile.bmp"); stage = new Stage(); Gdx.input.setInputProcessor(stage);//?? Image image = new Image(texture); image.setPosition(0, 0); image.setOrigin(0, 0); //stage.addActor(image); batch = new SpriteBatch(); }