List of usage examples for com.badlogic.gdx.utils.viewport FitViewport FitViewport
public FitViewport(float worldWidth, float worldHeight)
From source file:com.jltrem.video.VideoPlayerAndroid.java
License:Apache License
public VideoPlayerAndroid() { this(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); }
From source file:com.jmolina.orb.screens.BaseScreen.java
License:Open Source License
/** * Constructor/*from w w w. j a v a2 s . co m*/ */ public BaseScreen(SuperManager sm) { superManager = sm; periodicTimer = 0f; screenFlag = new ScreenFlag(); mainViewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); backgroundViewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); mainStage = new MainStage(mainViewport, getBackRunnable()); backgroundStage = new BackgroundStage(getAssetManager(), backgroundViewport); multiplexer = new InputMultiplexer(); mainStage.getRoot().setOrigin(VIEWPORT_WIDTH * 0.5f, VIEWPORT_HEIGHT * 0.5f); mainStage.getRoot().setSize(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); mainStage.getRoot().setScale(1f); mainStage.getRoot().setPosition(0f, 0f); addProcessor(mainStage); hierarchy = Hierarchy.LOWER; }
From source file:com.teotigraphix.gdx.app.Scene.java
License:Apache License
/** * Creates a new {@link Scene}./*from w ww .j a va 2s . co m*/ */ public Scene() { setStage(new Stage(new FitViewport(800f, 480f))); atlas = new TextureAtlas(Gdx.files.internal("skin.atlas")); skin = new Skin(atlas); }
From source file:me.scarlet.undertailor.engine.Environment.java
License:Open Source License
/** * Internal method.//w w w . j a v a 2 s.c om * * <p>Sets the viewport type.</p> */ void setViewport(Class<? extends Viewport> viewportType) { Viewport newPort = null; if (viewportType == FitViewport.class) { newPort = new FitViewport(640, 480); } else if (viewportType == StretchViewport.class) { newPort = new StretchViewport(640, 480); } if (newPort != null) { this.overworld.setViewport(newPort); } }
From source file:com.jmolina.orb.screens.Level.java
License:Open Source License
/** * Constructor//from w ww. j a va2s . c o m * * @param sm SuperManager */ public Level(SuperManager sm) { super(sm); achievedRobocop = false; achievedItsOver9000 = false; achievedHyperdrive = false; tick = new Tick(); pixelsPerMeter = getGameManager().getPixelsPerMeter(); impulse = IMPULSE_FACTOR / getPixelsPerMeter(); lastOrbPosition = new Vector2(); stats = new GameStats(); float worldWidth = VIEWPORT_WIDTH / getPixelsPerMeter(); float worldHeight = VIEWPORT_HEIGHT / getPixelsPerMeter(); worldViewport = new FitViewport(worldWidth, worldHeight); gestureViewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); parallaxViewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); hudViewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); hudStage = new HUDStage(this, getAssetManager(), hudViewport); gestureStage = new GestureStage(getAssetManager(), gestureViewport, getPixelsPerMeter()); parallaxStage = new ParallaxStage(getAssetManager(), parallaxViewport, getPixelsPerMeter()); worldManager = new WorldManager(); setOrb(new Orb(getAssetManager(), worldManager.getWorld(), getPixelsPerMeter())); worldManager.bindContactHandler(this, getOrb()); GestureDetector gestureDetector = new GestureDetector(GESTURE_HALF_TAP_SQUARE_SIZE, GESTURE_TAP_COUNT_INTERVAL, GESTURE_LONG_PRESS_DURATION, GESTURE_MAX_FLING_DELAY, new GestureHandler(this)); situationManager = new SituationManager(getAssetManager(), worldManager.getWorld(), getOrb(), getPixelsPerMeter(), getMainStage(), worldViewport); addProcessor(hudStage); addProcessor(gestureStage); addProcessor(gestureDetector); createRunnables(); disableTicking(); lock(); }
From source file:es.danirod.jddprototype.game.vista.GameScreen.java
License:Open Source License
/** * Create the screen. Since this constructor cannot be invoked before libGDX is fully started, * it is safe to do critical code here such as loading assets and setting up the stage. * @param game//from w ww . j a v a2 s . c om */ public GameScreen(es.danirod.jddprototype.game.controlador.MainGame game) { super(game); // instacia el atributo Preferences prefes_opciones = Gdx.app.getPreferences("jumpdontdie_opciones"); prefes_puntuaciones = Gdx.app.getPreferences("jumpdontdie_puntuaciones"); // carga las opciones if (prefes_opciones.getString("key").equals("creado")) { // compruebo si ya esta creado es.danirod.jddprototype.game.modelo.VariablesGlobales.volumen = prefes_opciones.getFloat("volumen"); es.danirod.jddprototype.game.modelo.VariablesGlobales.dificultad = prefes_opciones .getInteger("dificultad"); es.danirod.jddprototype.game.modelo.VariablesGlobales.personaje = prefes_opciones .getInteger("personaje"); } else { // si no esta cargado, pongo valores por defecto es.danirod.jddprototype.game.modelo.VariablesGlobales.volumen = 0.75f; es.danirod.jddprototype.game.modelo.VariablesGlobales.dificultad = 0; // facil es.danirod.jddprototype.game.modelo.VariablesGlobales.personaje = 0; // cubo } // carga las puntuaciones if (prefes_puntuaciones.getString("key").equals("creado")) { for (int i = 0; i < es.danirod.jddprototype.game.modelo.VariablesGlobales.punt.length; i++) { es.danirod.jddprototype.game.modelo.VariablesGlobales.punt[i] = prefes_puntuaciones .getInteger("punt" + (i + 1)); es.danirod.jddprototype.game.modelo.VariablesGlobales.nomb[i] = prefes_puntuaciones .getString("nomb" + (i + 1)); } } else { // si no esta creado pongo el valor por defecto de los String (los int se inicializan a 0) for (int i = 0; i < es.danirod.jddprototype.game.modelo.VariablesGlobales.punt.length; i++) { es.danirod.jddprototype.game.modelo.VariablesGlobales.nomb[i] = ""; } } // Create a new Scene2D stage for displaying things. stage = new Stage(new FitViewport(1280, 720)); // Load the skin file. The skin file contains information about the skins. It can be // passed to any widget in Scene2D UI to set the style. It just works, amazing. skin = new Skin(Gdx.files.internal("skin/uiskin.json")); // se crean los imagebutton tpausar = new Texture(Gdx.files.internal("pausa.png")); trpausar = new TextureRegion(tpausar); trdpausar = new TextureRegionDrawable(trpausar); pausar = new ImageButton(trdpausar); treanudar = new Texture(Gdx.files.internal("reanudar.png")); trreanudar = new TextureRegion(treanudar); trdreanudar = new TextureRegionDrawable(trreanudar); reanudar = new ImageButton(trdreanudar); // inicialmente ni se ve ni se puede interactuar con el boton para reanudar reanudar.setTouchable(Touchable.disabled); reanudar.setVisible(false); // definimos el corportamiento al pulsar el boton pausar pausar.addCaptureListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { pausa = true; pausar.setVisible(false); pausar.setTouchable(Touchable.disabled); reanudar.setVisible(true); reanudar.setTouchable(Touchable.enabled); backgroundMusic.stop(); } }); // definimos el corportamiento al pulsar el boton reanudar reanudar.addCaptureListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { pausa = false; pausar.setVisible(true); pausar.setTouchable(Touchable.enabled); reanudar.setVisible(false); reanudar.setTouchable(Touchable.disabled); backgroundMusic.play(); } }); // Create a new Box2D world for managing things. world = new World(new Vector2(0, -10), true); world.setContactListener(new GameContactListener()); // Get the sound effect references that will play during the game. jumpSound = game.getManager().get("audio/jump.ogg"); dieSound = game.getManager().get("audio/die.ogg"); backgroundMusic = game.getManager().get("audio/song.ogg"); sonidoVictoria = game.getManager().get("audio/victoria.ogg"); jumpSoundCR = game.getManager().get("audio/suuu.ogg"); // crea la imagenes flecha = new Image(game.getManager().get("flecha.png", Texture.class)); meta = new Image(game.getManager().get("meta.png", Texture.class)); noviste = new Image(game.getManager().get("noviste.png", Texture.class)); }