当前位置: 首页>>代码示例>>Java>>正文


Java FitViewport.apply方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.viewport.FitViewport.apply方法的典型用法代码示例。如果您正苦于以下问题:Java FitViewport.apply方法的具体用法?Java FitViewport.apply怎么用?Java FitViewport.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.viewport.FitViewport的用法示例。


在下文中一共展示了FitViewport.apply方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MenuScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:26,代码来源:MenuScreen.java

示例2: MenuScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
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);
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:24,代码来源:MenuScreen.java

示例3: create

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
@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);
  }
 
开发者ID:odedw,项目名称:TempoGDX,代码行数:20,代码来源:TempoGdxGame.java

示例4: GameScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
/**
 * 
 */
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);
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:25,代码来源:GameScreen.java

示例5: create

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
@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);
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:8,代码来源:PCMenu.java

示例6: RenderSystem

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
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");
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:11,代码来源:RenderSystem.java

示例7: SplashScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
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();
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:10,代码来源:SplashScreen.java

示例8: show

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
@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);
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:16,代码来源:TDScreen.java

示例9: AbstractScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
public AbstractScreen() {
        camera = new OrthographicCamera(GDefence.WIDTH, GDefence.HEIGHT);
        camera.setToOrtho(false, GDefence.WIDTH, GDefence.HEIGHT);
        viewport = new FitViewport(GDefence.WIDTH, GDefence.HEIGHT, camera);
        viewport.apply();

        stage = new Stage(viewport);
//        camera.position.set(camera.viewportWidth/2,camera.viewportHeight/2,0);
    }
 
开发者ID:mrDarkHouse,项目名称:GDefence,代码行数:10,代码来源:AbstractScreen.java

示例10: createViewport

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
private static FitViewport createViewport(IRenderEnv renderEnv) {
    FitViewport viewPort = new FitViewport(renderEnv.getWidth(), renderEnv.getHeight());
    GdxViewportUtil.setToOrtho(viewPort, renderEnv.getVirtualSize(), true);
    viewPort.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    viewPort.apply();
    return viewPort;
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:8,代码来源:RenderTestHelper.java

示例11: create

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
@Override
public void create() {
	camera = new OrthographicCamera();
	viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, camera);
	viewport.apply();

	assetManager = new AssetManager();
	batch = new SpriteBatch();

	titleScreen = new TitleScreen(this);
	this.setScreen(titleScreen);
}
 
开发者ID:bogdanguranda,项目名称:sokobug,代码行数:13,代码来源:Sokobug.java

示例12: initialize

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
private void initialize() {
    //LibGDX setup
    camera = new OrthographicCamera();
    viewPort = new FitViewport(256, 240, camera);
    viewPort.apply();
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
    shapeRenderer = new ShapeRenderer();
    shapeRenderer.setAutoShapeType(true);

    //Initialize shaders
    vertexShader = Gdx.files.internal("shaders/vertex_shader.glsl").readString();
    fragmentShader = Gdx.files.internal("shaders/fragment_shader.glsl").readString();
    shaderProgram = new ShaderProgram(vertexShader, fragmentShader);

    //Initialize attribute value (used by fragmentShader)
    initializeAttributes();

    //Make the mouse cursor transparent
    Pixmap pixmap = new Pixmap(16, 16, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.argb8888(0, 0, 0, 0));
    pixmap.fill();
    Gdx.graphics.setCursor(Gdx.graphics.newCursor(pixmap, 0, 0));
    pixmap.dispose();

    //Initialize transparent mask sprite
    transparentMaskPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
    transparentMaskPixmap.setColor(Color.CLEAR);
    transparentMaskPixmap.fill();
    transparentMaskTexture = new Texture(transparentMaskPixmap);
    transparentMaskSprite = new Sprite(transparentMaskTexture);

    //Initialize main frame buffer
    FrameBuffer.FrameBufferBuilder frameBufferBuilder = new FrameBuffer.FrameBufferBuilder(256, 240);
    frameBufferBuilder.addBasicColorTextureAttachment(Pixmap.Format.RGBA8888);
    mainFrameBuffer = frameBufferBuilder.build();

    mainTextureRegion = new TextureRegion(mainFrameBuffer.getColorBufferTexture(), 0, 0,
            256, 240);
    mainTextureRegion.flip(false, true);
    mainTextureRegion.getTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    //Initialize special frame buffer for foreground sprites so
    //we can hide them with fake background sprites
    foregroundSpritesFrameBuffer = frameBufferBuilder.build();
    foregroundSpritesTextureRegion = new TextureRegion(foregroundSpritesFrameBuffer.getColorBufferTexture(), 0, 0,
            256, 240);
    foregroundSpritesTextureRegion.flip(false, true);
    foregroundSpritesTextureRegion.getTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    //Initialize palette information
    palettePixmap = new Pixmap(32, 1, Pixmap.Format.RGBA8888);
    paletteTexture = new Texture(palettePixmap);
    masterPalette = loadPalette("palette/nespalette.bmp", 1, 1, 32, 32, 16, 4);
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:55,代码来源:RenderManager.java

示例13: GameScreen

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
public GameScreen() {
        entities.clear();
        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();

        earthTexture = new Sprite(new Texture(Gdx.files.internal("world.png")));
        musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png")));
        musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png")));
        earth = new Circle((float) (Game.WIDTH / 2 - Game.HEIGHT * 0.2), (float) (Game.HEIGHT / 2 - Game.HEIGHT * 0.2), (float) (Game.HEIGHT * 0.2));
        this.player = new Player();
        entities.add(player);
//        entities.add(new Sentry());
        Texture full = new Texture(Gdx.files.internal("meteorite.png"));
        meteoriteSprites = new Sprite[4];
        for (int i = 0; i < meteoriteSprites.length; i++) {
            TextureRegion region = new TextureRegion(full, i * 20, 0, 20, 20);
            meteoriteSprites[i] = new Sprite(region);
        }
        Texture full2 = new Texture(Gdx.files.internal("warning.png"));
        warningSprites = new Sprite[2];
        warningSprites[0] = new Sprite(new TextureRegion(full2, 0, 0, 9, 9));
        warningSprites[1] = new Sprite(new TextureRegion(full2, 9, 0, 9, 9));

        shopWindow = new ShopWindow();

        scoreFont = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false);
        scoreFont.getData().setScale(0.8f);

        leftButton = new Button(10, 10, 180, "buttons/control_button.png");
        rightButton = new Button(210, 10, "buttons/control_button.png");
        shopButton = new Button(Game.WIDTH - shopWindow.getShopWidth() - 190, 10, "buttons/shop_button.png");

        leftButton.setScale(1.5f);
        rightButton.setScale(1.5f);
        shopButton.setScale(1.5f);

        exit = new Button(1230, 450, "buttons/exit.png");
        pauseExit = new Button(1230, 450, "buttons/exit.png");
        retry = new Button(500, 450, "buttons/retry.png");
        resume = new Button(500, 450, "buttons/resume.png");
        music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted);
        music.setScale(4f);

        soundtrack = Gdx.audio.newMusic(Gdx.files.internal("sound/soundtrack.wav"));
        meteorDestroySound = Gdx.audio.newSound(Gdx.files.internal("sound/explosion.wav"));
        soundtrack.setLooping(true);
        if (!Game.musicMuted())
            soundtrack.play();
        //generating randomized background
        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);
        }
    }
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:62,代码来源:GameScreen.java

示例14: create

import com.badlogic.gdx.utils.viewport.FitViewport; //导入方法依赖的package包/类
/***
 * Initialisierung
 *
 * Diese Methode wird zum Start einmal aufgerufen.
 * Hier werden alle benötigten Variablen initialisiert.
 */
@Override
public void create() {
    Gdx.app.getApplicationLogger().log("INFO", "Init game...");

    camera = new OrthographicCamera();

    viewport = new FitViewport(1280, 720, camera);
    viewport.apply();

    gameState = new Splashscreen();
    gameState.create(this);

    inputMultiplexer = new InputMultiplexer();
    Gdx.input.setInputProcessor(inputMultiplexer);

    preferences = Gdx.app.getPreferences("de.entwicklerpages.java.schoolgame");

    String fontName = "Cormorant";
    if (!preferences.contains("use_pixel_font")) {
        preferences.putBoolean("use_pixel_font", false);
        preferences.flush();
    }

    if (preferences.getBoolean("use_pixel_font", false))
    {
        fontName = "VT323";
    }

    defaultFont = new BitmapFont(Gdx.files.internal("data/font/" + fontName + "_60.fnt"), false);
    //defaultFont.getData().setScale(4); // Skalierung (sollte vermieden werden)

    longTextFont = new BitmapFont(Gdx.files.internal("data/font/" + fontName + "_30.fnt"), false);
    titleFont = new BitmapFont(Gdx.files.internal("data/font/" + fontName + "_76.fnt"), false);

    if (shouldBeFullscreen())
    {
        Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
        Gdx.input.setCursorCatched(true);
    } else if (preferences.contains("window_width") && preferences.contains("window_height")) {
        Gdx.graphics.setWindowedMode(preferences.getInteger("window_width"), preferences.getInteger("window_height"));
    }
    Gdx.graphics.setVSync(shouldVSync());

    audioManager = new AudioManager(this);

    InputManager.getInstance().init(inputMultiplexer);

    Gdx.app.getApplicationLogger().log("INFO", "Finished.");
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:56,代码来源:SchoolGame.java


注:本文中的com.badlogic.gdx.utils.viewport.FitViewport.apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。