@Override public void create () { // a bitmap font to draw some text, note that we // pass true to the constructor, which flips glyphs on y font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), true); // a texture region, note the flipping on y again region = new TextureRegion(new Texture("data/badlogic.jpg")); region.flip(false, true); // a texture atlas, note the boolean atlas = new TextureAtlas(Gdx.files.internal("data/pack"), true); // a sprite, created from a region in the atlas sprite = atlas.createSprite("badlogicsmall"); sprite.setPosition(0, 0); // a sprite batch with which we want to render batch = new SpriteBatch(); // a camera, note the setToOrtho call, which will set the y-axis // to point downwards camera = new OrthographicCamera(); camera.setToOrtho(true); // a stage which uses our y-down camera and a simple actor (see MyActor below), // which uses the flipped region. The key here is to // set our y-down camera on the stage, the rest is just for demo purposes. stage = new Stage(); stage.getViewport().setCamera(camera); image = new MyActor(region); image.setPosition(100, 100); stage.addActor(image); // finally we write up the stage as the input process and call it a day. Gdx.input.setInputProcessor(stage); }
public RetroSceneScreen() { screenViewport = new SceneFitViewport(); worldViewport = new Viewport() { // This is the World Viewport. It is like a ScreenViewport but the // camera is the same that the screenViewport; @Override public void apply(boolean centerCamera) { HdpiUtils.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); getCamera().viewportWidth = getScreenWidth(); getCamera().viewportHeight = getScreenHeight(); if (centerCamera) getCamera().position.set(getScreenWidth() / 2, getScreenHeight() / 2, 0); getCamera().update(); } }; worldViewport.setCamera(screenViewport.getCamera()); }
public C2dStage(){ super(new FitViewport(Engine.getWidth(), Engine.getHeight()), Engine.getSpriteBatch()); this.getViewport().setCamera(Engine.getDefaultCamera()); //super(Engine.getWidth(), Engine.getHeight(), true, Engine.getSpriteBatch()); //this.setCamera(Engine.getDefaultCamera()); }
@Override public void render(SceneGraphRenderer sgr, ICamera camera, double t, int rw, int rh, FrameBuffer fb, PostProcessBean ppb) { boolean postproc = postprocessCapture(ppb, fb, rw, rh); // Viewport extendViewport.setCamera(camera.getCamera()); extendViewport.setWorldSize(rw, rh); extendViewport.setScreenSize(rw, rh); extendViewport.apply(); // Render sgr.renderScene(camera, t, rc); // Uncomment this to show the shadow map // if (GlobalConf.scene.SHADOW_MAPPING) { // // Render shadow map // int s = GlobalConf.scene.SHADOW_MAPPING_RESOLUTION; // sb.begin(); // for (int i = 0; i < sgr.shadowMapFb.length; i++) { // sb.draw(sgr.shadowMapFb[i].getColorBufferTexture(), 0, 0, s, s); // } // sb.end(); // } postprocessRender(ppb, fb, postproc, camera, rw, rh); }
aiViewport.setCamera(aiCam); aiViewport.setWorldSize(indicatorw, indicatorh); aiViewport.setScreenBounds((int) indicatorx, (int) indicatory, (int) indicatorw, (int) indicatorh);
viewport.setCamera(cam); viewport.setWorldSize(wh, wh); viewport.setScreenBounds(0, 0, wh, wh);