Java 类com.badlogic.gdx.utils.viewport.FitViewport 实例源码

项目:feup-lpoo-armadillo    文件:MenuScreen.java   
/**
 * Menu Screen's constructor.
 * It initializes all the Menu elements.
 *
 * @param game The current game session.
 */
protected MenuScreen(final Armadillo game) {
    this.game = game;
    batch = game.getBatch();
    gameServices = game.getGameServices();
    skin1 = game.getPrimarySkin();
    skin2 = game.getSecondarySkin();

    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
    viewport.apply();

    stage = new Stage(viewport, batch);

    backgroundImg = new Image(game.getAssetManager().get("background.png", Texture.class));
    backgroundImg.setScale(VIEWPORT_WIDTH / backgroundImg.getWidth(), VIEWPORT_HEIGHT / backgroundImg.getHeight());

    titleImg = new Image(game.getAssetManager().get("armadillo_title.png", Texture.class));
    titleImg.setSize(0.8f * titleImg.getWidth(), 0.8f * titleImg.getHeight());
    titleImg.setPosition(VIEWPORT_WIDTH / 2 - titleImg.getWidth() / 2, VIEWPORT_HEIGHT * 0.98f - titleImg.getHeight());
}
项目:Parasites-of-HellSpace    文件:GameScreen.java   
@Override
public void show() 
{
    fpsLogger = new FPSLogger();

    batch = new SpriteBatch();
    camera = new OrthographicCamera(500, 800);
    viewport = new FitViewport(500, 800, camera);
    player = new Player();
    player.create();

    background = new Background();
    background.create();

    spawningFactory = new SpawningFactory();
    spawningFactory.create();

    spawningEnemy = new SpawningEnemy();
    spawningEnemy.create();

    spawningBullet = new SpawningBullet();
    spawningBullet.create();

    ui = new UI();
    ui.create();
}
项目:EarthInvadersGDX    文件:MenuScreen.java   
public MenuScreen() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
    viewport.apply();
    camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
    camera.update();
    betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
    betaText.getData().setScale(0.35f);
    logo = new Sprite(new Texture("logo.png"));
    Random r = new Random();
    background = new Particle[r.nextInt(55 - 45) + 45];
    for (int i = 0; i < background.length; i++) {
        int size = r.nextInt(4) + 1;
        int x = r.nextInt(Game.WIDTH);
        int y = r.nextInt(Game.HEIGHT);
        background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size);
    }
    musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
    musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
    play = new CenteredButton(500, "buttons/play.png");
    music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
    music.setScale(4f);
}
项目:Ponytron    文件:DS.java   
public static void init(DSGame game) {
        OPT = new PreferenceAssist();
        if(app_orientation == LANDSCAPE) {
            T_HEIGHT = 1080;
            T_WIDTH = 1920;
        } else {
            T_WIDTH = 1080;
            T_HEIGHT = 1920;
//            T_WIDTH = 720;
//            T_HEIGHT = 1280;
        }

        camera = new OrthographicCamera();
        camera.position.set((int)(DS.T_WIDTH/2.0), (int)(DS.T_HEIGHT/2.0), 0);
        viewport = new FitViewport(DS.T_WIDTH, DS.T_HEIGHT, camera);
        DS.game = game;
        sb = new SpriteBatch(150);

        Gdx.app.setLogLevel(Application.LOG_DEBUG);
    }
项目:arcadelegends-gg    文件:DefaultLoadingScreen.java   
public void show() {
    if (!init) {
        loadingScreenAssets = new Assets.LoadingScreenAssets();
        AL.getAssetManager().loadAssetFields(loadingScreenAssets);
        AL.getAssetManager().finishLoading();
        font = new BitmapFont();
        batch = new SpriteBatch();

        cam = new OrthographicCamera();
        viewport = new FitViewport(1920, 1080);
        viewport.setCamera(cam);
        stage = new Stage(viewport);
        stage.setViewport(viewport);
        skin = loadingScreenAssets.styles_json;

        loadingScreenBar = new ProgressBar(0, 100, 1, false, skin);
        loadingScreenBar.setPosition(25, -10);
        loadingScreenBar.setSize(1890, 50);

        stage.addActor(loadingScreenBar);
    }
    init = true;
}
项目:arcadelegends-gg    文件:MainMenuScreen.java   
/**
 * Method responsible for initializing the main menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    AL.getAudioManager().registerMusic("bitrush", menuAssets.bitrush);
    AL.getAudioManager().playMusic("bitrush");

    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = menuAssets.styles_json;
    skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = menuAssets.testmainscreen;

    initButtons();
    AL.input.setInputProcessor(stage);
}
项目:arcadelegends-gg    文件:InputSettingsScreen.java   
/**
 * Method responsible for initializing the main menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = settingsAssets.styles_json;
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = settingsAssets.testmainscreen;
    BitmapFont font = settingsAssets.bocklin_fnt;
    TextureRegion backgroundTexture = new TextureRegion(settingsAssets.background_textbutton);

    inputTable = new Table();
    keys = IInputConfig.InputKeys.values();
    keyMap = new HashMap<>();

    initInputRows(font, backgroundTexture);
    createBackButton();
    AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
项目:arcadelegends-gg    文件:GameOverScreen.java   
/**
 * Method responsible for initializing the GameOverScreen
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = menuAssets.styles_json;
    skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = menuAssets.testmainscreen;

    createComponents();



    AL.input.setInputProcessor(stage);
}
项目:arcadelegends-gg    文件:PauseMenuScreen.java   
/**
 * Method responsible for initializing the pause menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    // Inits:
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = menuAssets.styles_json;
    skin.getFont("bocklin").getData().setScale(0.8f, 0.8f);
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = menuAssets.testmainscreen;

    createComponents();

    AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
项目:arcadelegends-gg    文件:RenderSystem.java   
public RenderSystem(DecalBatch decalBatch, AssetManager assetManager, float worldDegree, Assets.LevelAssets assets) {
    super(Aspect.all(RenderComponent.class, PositionComponent.class));
    this.levelAssets = assets;
    decalMap = new ObjectMap<>();
    uiMap = new ObjectMap<>();
    this.decalBatch = decalBatch;
    this.assetManager = assetManager;
    buffers = new ObjectMap<>();

    this.spriteBatch = new SpriteBatch();
    this.font = assets.uifont;
    font.setColor(Color.BLACK);
    this.uiCamera = new OrthographicCamera();

    Viewport viewportUi = new FitViewport(levelAssets.health_bar_gradient.getWidth(), levelAssets.health_bar_gradient.getHeight(), uiCamera);
    viewportUi.update(viewportUi.getScreenWidth(), viewportUi.getScreenHeight(), true);

    stateTime = 0;
    this.worldDegree = worldDegree;

    gradientShader = new ShaderProgram(Shaders.GradientShader.vertexShader, Shaders.GradientShader.fragmentShader);
    if (gradientShader.isCompiled() == false)
        throw new IllegalArgumentException("couldn't compile shader: " + gradientShader.getLog());
    shaderBatch = new SpriteBatch(10, gradientShader);
}
项目:DarkDay    文件:Hud.java   
public Hud(SpriteBatch sb) {
    countKill = 0;
    viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());

    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.setFillParent(true);
    table.top();

    countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(countKillLabel).expandX().padTop(10);
    table.add().expandX();
    table.add().expandX();
    table.add().expandX();
    stage.addActor(table);

}
项目:nomoore    文件:MyGdxGame.java   
@Override
public void create() {
    if (androidInterface != null)
        androidInterface.tryToStopMusicApp();

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

    camera = new OrthographicCamera();
    viewport = new FitViewport(Configuration.WINDOW_WIDTH, Configuration.WINDOW_HEIGHT, camera);
    camera.position.set(viewport.getWorldWidth() / 2 - (viewport.getWorldWidth() - 500) / 2, viewport.getWorldHeight() / 2 - (viewport.getWorldHeight() - 220) / 2, 0);
    camera.update();

    fade = new Sprite(new Texture("sprites/fade.png"));
    fade.setBounds(0, -100, viewport.getWorldWidth(), viewport.getWorldHeight() - 40);

    font = new BitmapFont(Gdx.files.internal("fonts/amiga4everpro2.fnt"));

    showModernTimesCutscene(); // start the game
}
项目:jewelthief    文件:LogoScreen.java   
public LogoScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport, OrthographicCamera camera) {
    this.batch = batch;
    this.shapeRenderer = shapeRenderer;
    this.viewport = viewport;
    this.camera = camera;

    spriteThere = new Sprite(new Texture("there.png"));
    spriteFactory = new Sprite(new Texture("factory.png"));
    spriteLibGdxLogo = new Sprite(new Texture("libgdx.png"));

    AssetManager am = JewelThief.getInstance().getAssetManager();
    am.load("audio/sounds/keyboard.ogg", Sound.class);
    am.load("audio/sounds/keyboard_go_back.ogg", Sound.class);
    am.load("audio/sounds/re.ogg", Sound.class);
    am.load("audio/sounds/libgdx.ogg", Music.class);
    am.finishLoading();

    soundTypeTheRefactory = am.get("audio/sounds/keyboard.ogg", Sound.class);
    soundGoBackOnKeyboard = am.get("audio/sounds/keyboard_go_back.ogg", Sound.class);
    soundTypeRe = am.get("audio/sounds/re.ogg", Sound.class);
    musicLibGdxJingle = am.get("audio/sounds/libgdx.ogg", Music.class);

    resetAnimation();
}
项目:Longest-Century    文件:OptionsScreen.java   
public OptionsScreen(Launcher launcher) {
    this.launcher = launcher;

    viewport = new FitViewport(1920, 1080);
    camera = new OrthographicCamera();

    stage = new Stage(viewport, launcher.batch);
    skin = new Skin(Gdx.files.internal("gfx/skin/uiskin.json"));

    menu = new TextButton("MENU", skin, "default");
    menu.setPosition(32, 48);

    menu.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            launcher.setScreen(new MenuScreen(launcher));
        }
    });
    stage.addActor(menu);

    Gdx.input.setInputProcessor(stage);
}
项目:DunGen    文件:MapGenDebugRenderer.java   
public MapGenDebugRenderer(GameMap map) {
    this.map = map;

    boundingBox = map.boundingBox;
    Vector2 boundingBoxCenter = new Vector2();
    boundingBox.getCenter(boundingBoxCenter);

    int boundingBoxWidth = ((int) boundingBox.width);
    int boundingBoxHeight = ((int) boundingBox.height);

    camera = new OrthographicCamera(boundingBoxWidth + CAMERA_OFFSET, boundingBoxHeight + CAMERA_OFFSET);
    camera.position.x = boundingBoxCenter.x;
    camera.position.y = boundingBoxCenter.y;
    camera.update();

    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(camera.combined);

    viewport = new FitViewport(boundingBoxWidth, boundingBoxHeight, camera);
}
项目:joe    文件:HUD.java   
private HUD() {
    stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
    stage.addListener(inputListener = new InputListener(true));
    Gdx.input.setInputProcessor(stage);

    fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
    skin = new Skin(Gdx.files.internal("uiskin.json"));
    createFlashImage();
    createProgressLabel();
    createInfoLabel();
    createLevelCompleteUI();
    hideLevelComplete();

    if (Globals.isMobile()) {
        createMobileButtons();
    }
}
项目:Freaking-Math    文件:HudOver.java   
public HudOver(MyGame game, freakingMath fm2){

    this.game=game;
    this.fm2=fm2;
    viewport=new FitViewport(conf.width,conf.height,new OrthographicCamera());
    stage=new Stage(viewport);

    initLabels();
    initImages();


    stage.addActor(gameOverI);
    stage.addActor(scoreL);
    stage.addActor(highL);
    stage.addActor(MenuI);
    stage.addActor(playI);
    stage.addAction(moveTo(conf.width/2-gameOverI.getWidth()/2,conf.height*3/2));
}
项目:TempoGDX    文件:TempoGdxGame.java   
@Override

  public void create() {
    batch = new SpriteBatch();
    Assets.load();
    Assets.finishLoading();
    background = Assets.getTexture("background");
    background.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);

    viewport = new FitViewport(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT);
    viewport.apply();
    mainScreen = new MainScreen(viewport, this);
    infoScreen = new InfoScreen(viewport, this);

    //workaround for sound not playing on mobile
    silenceLoopId = Assets.getSound("silence").loop();

    setScreen(mainScreen);
  }
项目:advio    文件:Advio.java   
@Override
public void create() {
    instance = this;
    constants = new Constants();
    font = new BitmapFont(Gdx.files.internal("font.fnt"));
    font.setColor(0, 0, 0, 1);
    sfont = new BitmapFont(Gdx.files.internal("font.fnt"));
    sfont.setColor(0, 0, 0, 1);
    sfont.getData().setScale(0.75f);
    port = new FitViewport(1280, 720);
    music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
    Advio.instance.console = new Console(Advio.instance.getScreen());
    resetMusic(music);
    music.play();
    setScreen(menu = new MenuScreen());
}
项目:gdx-pd    文件:GdxPdTests.java   
@Override
public void create () 
{
    PdConfiguration config = new PdConfiguration();
    config.inputChannels = 1;
    Pd.audio.create(config);

    // new ScreenViewport()
    stage = new Stage(new FitViewport(800, 600));

    skin = new Skin(Gdx.files.internal("skins/uiskin.json"));

    Table root = new Table();
    root.defaults().pad(10);


    Gdx.input.setInputProcessor(stage);
}
项目:jumpdontdie    文件:GameScreen.java   
/**
 * 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
 */
public GameScreen(es.danirod.jddprototype.game.MainGame game) {
    super(game);

    // Create a new Scene2D stage for displaying things.
    stage = new Stage(new FitViewport(640, 360));
    position = new Vector3(stage.getCamera().position);

    // 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");
}
项目:abattle    文件:BasicScreen.java   
public BasicScreen() {
  MyStage _myStage = new MyStage();
  this.stage = _myStage;
  FitViewport _fitViewport = new FitViewport(BasicScreen.VIRTUAL_WIDTH, BasicScreen.VIRTUAL_HEIGHT);
  this.viewport = _fitViewport;
  this.stage.setViewport(this.viewport);
  this.stage.setHardKeyListener(this);
  Widgets _widgets = new Widgets(this.stage);
  this.widgets = _widgets;
  this.addLogo();
  this.addHelpLine();
  this.create();
  Camera _camera = this.stage.getCamera();
  BackgroundRender _backgroundRender = new BackgroundRender(_camera);
  this.backgroundRenderer = _backgroundRender;
}
项目:Bomberman_libGdx    文件:GameOverScreen.java   
@Override
public void show() {
    viewport = new FitViewport(640, 480);
    stage = new Stage(viewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/foo.fnt"));

    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);
    Label gameOverLabel = new Label("Game Over", labelStyle);
    gameOverLabel.setPosition((640 - gameOverLabel.getWidth()) / 2, 226f);

    GameManager.getInstance().playMusic("GameOver.ogg", false);

    stage.addActor(gameOverLabel);

    stage.addAction(Actions.sequence(
            Actions.delay(1f),
            Actions.fadeOut(2f),
            Actions.run(new Runnable() {
                @Override
                public void run() {
                    game.setScreen(new MainMenuScreen(game));
                }
            })));

}
项目:libgdx_mario    文件:GameOverScreen.java   
public GameOverScreen(MarioBros game) {
    this.game = game;
    viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, game.batch);

    Label.LabelStyle font = new Label.LabelStyle(new BitmapFont(), Color.WHITE);

    Table table = new Table();
    table.center();
    table.setFillParent(true);


    Label gameOverLabel = new Label("GAME OVER", font);
    Label playAgainLabel = new Label("Click to play again", font);
    table.add(gameOverLabel).expandX();
    table.row();
    table.add(playAgainLabel).padTop(10).expandX();

    stage.addActor(table);
}
项目:green-fifteen-gdx    文件:GameScreen.java   
public GameScreen(FifteenGame game) {
    this.game = game;

    camera = new OrthographicCamera();
    camera.setToOrtho(false, SIZE, SIZE);

    viewport = new FitViewport(SIZE, SIZE, camera);

    allNumbers = new Texture(Gdx.files.internal("fifteen_240.png"));

    fifteen = new Fifteen();
    shuffler = new Shuffler(fifteen);
    blockService = new BlockService();
    positionService = new PositionService(SIZE, SIZE);
    initBlocks();
    shuffleBoard();
}
项目:killingspree    文件:ClientDiscoveryScreen.java   
@Override
public void show() {
    client = new Client();
    client.start();
    font = game.getFont(120);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
    buttons = new ArrayList<MyButton>();
    ipAddresses = new ArrayList<MyButton>();
    markForDispose = false;
    addAllButtons();
    addIpButtons();
    pressedButton = false;
}
项目:SupaBax    文件:GameScreen.java   
/**
 * 
 */
public GameScreen(SupaBox game) {
    this.game = game;

    //float aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth();

    camera = new OrthographicCamera();
    viewport = new FitViewport(24, 16, camera);
    viewport.apply();

    camera.position.set(viewport.getWorldWidth() / 2, viewport.getWorldHeight() / 2, 0);

    debugRenderer = new Box2DDebugRenderer();
    world = new World(new Vector2(0, -9.8f), true);

    mapLoader = new TmxMapLoader();
    map = mapLoader.load("crate.tmx");
    mapRenderer = new OrthogonalTiledMapRenderer(map, 1f / SupaBox.PPM);

    bodyBuilder = new BodyBuilder();
    bodyBuilder.createBodies(entities, world, map);
}
项目:gdx-lml    文件:Core.java   
@Override
public void create() {
    // Creating UI with gdx-lml-vis:
    stage = new Stage(new FitViewport(WIDTH, HEIGHT));
    Gdx.input.setInputProcessor(stage);
    VisUI.load();
    VisLml.parser().build().createView(this, Gdx.files.internal("core.lml"));
    // Smooth screen fading in:
    stage.addAction(Actions.sequence(Actions.alpha(0f), Actions.alpha(1f, 1f)));

    // Connecting with the server:
    for (final WebSocketTest test : tests) {
        test.setListener(this);
        test.connect("localhost");
    }
}
项目:gdx-lml    文件:Core.java   
@Override
public void create() {
    // Note: you can also use WebSockets.newSocket() and WebSocket.toWebSocketUrl() methods.
    socket = ExtendedNet.getNet().newWebSocket("localhost", 8000);
    socket.addListener(getListener());
    // Creating a new ManualSerializer - this replaces the default JsonSerializer and allows to use the
    // serialization mechanism from gdx-websocket-serialization library.
    final ManualSerializer serializer = new ManualSerializer();
    socket.setSerializer(serializer);
    // Registering all expected packets:
    MyPackets.register(serializer);

    // Creating UI with gdx-lml-vis:
    stage = new Stage(new FitViewport(WIDTH, HEIGHT));
    Gdx.input.setInputProcessor(stage);
    VisUI.load();
    VisLml.parser().build().createView(this, Gdx.files.internal("core.lml"));
    // Smooth screen fading in:
    stage.addAction(Actions.sequence(Actions.alpha(0f), Actions.alpha(1f, 1f)));

    // Connecting with the server.
    socket.connect();
}
项目:ud406    文件:RectangleCircleCollisionScreen.java   
public RectangleCircleCollisionScreen() {
    startTime = TimeUtils.nanoTime();
    shapeRenderer = new ShapeRenderer();
    viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);

    rectangles = new Array<Rectangle>(new Rectangle[]{
            new Rectangle(40, 40, 20, 20), // Middle
            new Rectangle(10, 40, 10, 20), // Left
            new Rectangle(70, 45, 20, 10) // Right
    });

    circles = new Array<OscillatingCircle>(new OscillatingCircle[]{
            new OscillatingCircle(50, 65, 7, 0, 40, 3), // High horizontal
            new OscillatingCircle(50, 35, 7, 0, 40, 3.1f), // Low horizontal
            new OscillatingCircle(50, 50, 3, MathUtils.PI / 4, 40, 5f), // Diagonal
            new OscillatingCircle(25, 50, 5, 0, 11, 7f), // Middle horizontal
    });
}
项目:ud406    文件:RectangleCircleCollisionScreen.java   
public RectangleCircleCollisionScreen() {
    startTime = TimeUtils.nanoTime();
    shapeRenderer = new ShapeRenderer();
    viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);

    rectangles = new Array<Rectangle>(new Rectangle[]{
            new Rectangle(40, 40, 20, 20), // Middle
            new Rectangle(10, 40, 10, 20), // Left
            new Rectangle(70, 45, 20, 10) // Right
    });

    circles = new Array<OscillatingCircle>(new OscillatingCircle[]{
            new OscillatingCircle(50, 65, 7, 0, 40, 3), // High horizontal
            new OscillatingCircle(50, 35, 7, 0, 40, 3.1f), // Low horizontal
            new OscillatingCircle(50, 50, 3, MathUtils.PI / 4, 40, 5f), // Diagonal
            new OscillatingCircle(25, 50, 5, 0, 11, 7f), // Middle horizontal
    });
}
项目:libgdxcn    文件:ViewportTest1.java   
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);

    viewports.add(new ScalingViewport(Scaling.none, minWorldWidth, minWorldHeight, camera));
    return viewports;
}
项目:HAW-SE2-projecthorse    文件:SplashScreen.java   
/**
 * Konstruktor.
 */
public SplashScreen() {

    cam = createCamera();
    viewport = new FitViewport(width, height, cam);

    spriteBatch = new SpriteBatch();
    spriteBatch.setProjectionMatrix(cam.combined);
    stage = new Stage(viewport, spriteBatch);
    image = new Image(new TextureRegionDrawable(new TextureRegion(new Texture(
            Gdx.files.internal("splashscreen/Background.png")))));
    createButton();
    initTable();

    table.addActor(textContent);

    stage.addActor(image);
    stage.addActor(table);
}
项目:Hakd    文件:DeviceScene.java   
public void open() {
        Gdx.input.setInputProcessor(stage);
        stage.setViewport(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));

        if (desktop == null) {
            terminal0 = new Terminal(this);
            terminal1 = new Terminal(this);
            terminal2 = new Terminal(this);
            terminal3 = new Terminal(this);
//            login = new Login();
//            web = new Web();
            info = new Info(this);
            shutdown = new Shutdown(this);
            textEdit = new TextEdit(this);

            desktop = new Desktop(this); // has to be last, this creates the DesktopAppIcons
        }

        desktop.open(); // default screen when you open the server, I may change it to a login or startup screen
    }
项目:ggvm    文件:PCMenu.java   
@Override
public void create() {
    camera = new OrthographicCamera();
    viewPort = new FitViewport(256, 240, camera);
    viewPort.apply();
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
}
项目:penguins-in-space    文件:RenderSystem.java   
public RenderSystem(Batch batch) {
    super(FAMILY);
    this.camera = new OrthographicCamera();
    viewport = new FitViewport(Asteroids.VIRTUAL_WIDTH, Asteroids.VIRTUAL_HEIGHT, camera);
    viewport.apply(true);
    this.batch = batch;
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setColor(Color.RED);
    font = ServiceLocator.getAppComponent().getAssetService().getSkin(AssetService.SkinAsset.UISKIN).getFont("default-font");
}
项目:conquest    文件:Match.java   
public Match(Client client, Player player) {
    Match.client = client;
    this.tiles = Match.client.getMap();
    this.player = player;

    cam = new ConquestCamera(this.tiles);
    stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), cam));

    Group tileGroup = new Group();
    Group labelGroup = new Group();
    for (Tile t : this.tiles) {
        t.setTexture();
        tileGroup.addActor(t);
        labelGroup.addActor(t.getLabel());
    }

    Tile random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    while (random.getOwner() != Owner.None) {
        random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    }
    player.setCapital(random);
    client.send(random);

    cam.position.set(random.getX(Align.center), random.getY(Align.center), 0);

    stage.addActor(tileGroup);
    stage.addActor(labelGroup);
}
项目:EarthInvadersGDX    文件:SplashScreen.java   
public SplashScreen() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera);
    viewport.apply();
    camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0);
    camera.update();
    logo = new Sprite(new Texture(Gdx.files.internal("gussio.png")));
    initiateTime = System.currentTimeMillis();
}
项目:Tower-Defense-Galaxy    文件:TDScreen.java   
@Override
public void show () {
    //orthographicCamera = new OrthographicCamera(3840, 2160);
    matrix4 = new Matrix4();
    spriteBatch = new SpriteBatch();
    viewport = new FitViewport(2560, 1440, new OrthographicCamera());
    viewport.apply();
    stage = new Stage(viewport);
    camera = createCamera();
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(stage);
    Gdx.input.setInputProcessor(multiplexer);
    if(TDGalaxy.preferences.isDebug())
        stage.setDebugAll(true);
}
项目:summer17-android    文件:Hud.java   
public Hud(SpriteBatch sb) {
        worldTimer = 300;
        timeCount = 0;
        score = 0;

        viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
        stage = new Stage(viewport, sb);

        Table table = new Table();
        table.top();
        table.setFillParent(true);

//        countDownLabel = new Label(String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        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));
//        dudeLabel = new Label("DUDE", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

        table.add(dudeLabel).expandX().padTop(10);
        table.add(worldLabel).expandX().padTop(10);
        table.add(timeLabel).expandX().padTop(10);
        table.row();
        table.add(scoreLabel).expandX();
        table.add(levelLabel).expandX();
        table.add(countDownLabel).expandX();

        stage.addActor(table);
    }