當前位置: 首頁>>代碼示例>>Java>>正文


Java OrthographicCamera.update方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.OrthographicCamera.update方法的典型用法代碼示例。如果您正苦於以下問題:Java OrthographicCamera.update方法的具體用法?Java OrthographicCamera.update怎麽用?Java OrthographicCamera.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.OrthographicCamera的用法示例。


在下文中一共展示了OrthographicCamera.update方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEnter

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
public void onEnter() {
	super.onEnter();
	
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();

	camera = new OrthographicCamera();
	camera.setToOrtho(false, (w / h) * 640, 640);
	camera.update();
	
	map = new TmxMapLoader().load("Resource/tiles.tmx");
	renderer = new OrthogonalTiledMapRenderer(map, 2f);//1f / 32f);
	
	func = CC.Scheduler().renderAfterSchedulePerFrame((t)->{
		camera.position.set(500, 320, 0);
		camera.update();
		renderer.setView(
				camera.combined,
				0, 0, 1000, 500);
		renderer.render();
		return false;
	}, 0, false);
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:24,代碼來源:TiledMapTests.java

示例2: createCamera

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
/**
 * Creates a new Orthographic Camera for the Game.
 *
 * @return the created camera.
 */
private OrthographicCamera createCamera() {
    OrthographicCamera camera = new OrthographicCamera(VIEWPORT_WIDTH / PIXEL_TO_METER,
            VIEWPORT_HEIGHT / PIXEL_TO_METER);

    camera.position.set(model.getBallModel().getX() / PIXEL_TO_METER,
            model.getBallModel().getY() / PIXEL_TO_METER, 0);
    camera.update();

    if (DEBUG_PHYSICS) {
        debugRenderer = new Box2DDebugRenderer();
        debugCamera = camera.combined.cpy();
        debugCamera.scl(1 / PIXEL_TO_METER);
    }

    return camera;
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:22,代碼來源:GameScreen.java

示例3: MenuScreen

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的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

示例4: initUtils

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
private void initUtils() {
    //init camera & viewport
    camera = new OrthographicCamera();
    viewport = new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT, camera);
    viewport.apply(true);
    camera.update();

    //init sprite batch
    batch = new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);

    //init font
    FreeTypeFontGenerator fontGenerator = polymorph.getAssetManager().get(Polymorph.FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    FreeTypeFontParameter fontSettings = new FreeTypeFontParameter();
    fontSettings.size = 80;
    fontSettings.minFilter = TextureFilter.Linear;
    fontSettings.magFilter = TextureFilter.Linear;
    font = fontGenerator.generateFont(fontSettings);
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:20,代碼來源:GameScreen.java

示例5: read

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@Override
public OrthographicCamera read(Kryo kryo, Input input, Class<OrthographicCamera> type) {
    OrthographicCamera camera = new OrthographicCamera();
    Vector3 position = kryo.readObject(input, Vector3.class);
    Vector3 direction = kryo.readObject(input, Vector3.class);
    Vector3 up = kryo.readObject(input, Vector3.class);
    camera.position.set(position);
    camera.direction.set(direction);
    camera.up.set(up);
    camera.near = input.readFloat();
    camera.far = input.readFloat();
    camera.viewportWidth = input.readFloat();
    camera.viewportHeight = input.readFloat();
    camera.zoom = input.readFloat();
    camera.update();
    return camera;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:18,代碼來源:OrthographicCameraSerializer.java

示例6: create

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@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
}
 
開發者ID:cdetamble,項目名稱:nomoore,代碼行數:21,代碼來源:MyGdxGame.java

示例7: init

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
private void init() {
    batch = new SpriteBatch();
    camera = new OrthographicCamera(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT);
    camera.position.set(0, 0, 0);
    camera.update();

    cameraGUI = new OrthographicCamera(Constants.VIEWPORT_GUI_WIDTH, Constants.VIEWPORT_GUI_HEIGHT);
    cameraGUI.position.set(0, 0, 0);
    cameraGUI.setToOrtho(true);
    cameraGUI.update();
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:12,代碼來源:WorldRenderer.java

示例8: SplashScreen

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的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

示例9: copy

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@Override
public OrthographicCamera copy (Kryo kryo, OrthographicCamera original) {
    OrthographicCamera camera = new OrthographicCamera();
    camera.position.set(original.position);
    camera.direction.set(original.direction);
    camera.up.set(original.up);
    camera.near = original.near;
    camera.far = original.far;
    camera.viewportWidth = original.viewportWidth;
    camera.viewportHeight = original.viewportHeight;
    camera.zoom = original.zoom;
    camera.update();
    return camera;
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:15,代碼來源:OrthographicCameraSerializer.java

示例10: create

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@Override
public void create () {
	// When game is started
	
	// Graphics 
	spriteBatch = new SpriteBatch();
	
	// Audio
	musicManager = new MusicManager();
	soundManager = new SoundManager();
	
	// Setting Cameras to the size of the game window
	cam = new OrthographicCamera(WIDTH, HEIGHT);
	viewport = new ExtendViewport(WIDTH, HEIGHT, cam);
	cam.position.set(cam.viewportWidth / 2f, cam.viewportHeight / 2f, 0);
	cam.update(); // commit cam changes from translate

	
	// Start Keyboard Input
	input = new GameInputProcessor();
	Gdx.input.setInputProcessor(input);
	
	// Start Image Manager
	imageManager = new ImageManager();
	
	// Start Game State Manager
	gsm = new GameStateManager(this);

}
 
開發者ID:ja-brouil,項目名稱:StarshipFighters,代碼行數:30,代碼來源:Game.java

示例11: create

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@Override
public void create()
{
	// DisplayMode[] dms = Gdx.graphics.getDisplayModes();
	// Texture.setEnforcePotImages(false);

	bivSettings = new BIVSettings();
	bivSettings.Load();
	float w = fScreenWidth = iScreenWidth = Gdx.graphics.getWidth();
	float h = fScreenHeight = iScreenHeight = Gdx.graphics.getHeight();

	camera = new OrthographicCamera(w, h);
	camera.setToOrtho(false, w, h);
	camera.update();

	batch = new SpriteBatch();

	nightModeManager = new NightModeManager();
	
	Gdx.input.setInputProcessor(myInputProcessor);

	ui = new UI();

	if (bivSettings.restartBorderlessToggle)
	{
		// The restartBorderlessToggle flag should no longer be used.
		bivSettings.restartBorderlessToggle = false;
		bivSettings.Save();
		ui.openWindow(MainOptionsWnd.class);
		ui.openWindow(WindowOptionsWnd.class);
	}

	texLightGray = Create1x1ColorTexture(new Color(0.667f, 0.667f, 0.667f, 0.667f));
	texDarkGreen = Create1x1ColorTexture(new Color(0f, 0.444f, 0f, 0.5f));
	texDarkGray = Create1x1ColorTexture(new Color(0.333f, 0.333f, 0.333f, 0.5f));
	texRed = Create1x1ColorTexture(new Color(1f, 0f, 0f, 0.667f));

	images = new Images();
	images.Initialize();
}
 
開發者ID:bp2008,項目名稱:blueirisviewer,代碼行數:41,代碼來源:BlueIrisViewer.java

示例12: ScreenManager

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
public ScreenManager() {
    float width = Gdx.graphics.getWidth();
    float height = Gdx.graphics.getHeight();
    oc = new OrthographicCamera(width * 2, width * 2 * (height / width));
    oc.position.set(oc.viewportWidth / 2f, oc.viewportHeight/2, 0);
    oc.update();
    sb = new SpriteBatch();
}
 
開發者ID:elitej13,項目名稱:project-divine-intervention,代碼行數:9,代碼來源:ScreenManager.java

示例13: applyTo

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
public void applyTo(OrthographicCamera camera) {
	camera.position.x = position.x;
	camera.position.y = position.y;
	camera.zoom = zoom;
	camera.update();
}
 
開發者ID:davyjoneswang,項目名稱:libgdx-learnlib,代碼行數:7,代碼來源:CameraHelper.java

示例14: GameScreen

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的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

示例15: show

import com.badlogic.gdx.graphics.OrthographicCamera; //導入方法依賴的package包/類
@Override
public void show() {
    // ui
    hud = new HudScene(spriteBatch, shapeRenderer, arcRenderer);

    //input
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(hud.getStage());
    multiplexer.addProcessor(new GestureDetector(new GameGestureProcessor(this)));
    multiplexer.addProcessor(new GameInputProcessor(this));
    Gdx.input.setInputProcessor(multiplexer);

    // map
    map = new TmxMapLoader().load("maps/" + level.getFile());

    mapHeight = map.getProperties().get("height", 40, int.class);
    mapWidth = map.getProperties().get("width", 15, int.class);

    tilewidth = map.getProperties().get("tilewidth", 128, int.class);

    // renderer
    float unitScale = 1 / (float) tilewidth;
    tiledMapRenderer = new OrthogonalTiledMapRenderer(map, unitScale);

    // camera
    camera = new OrthographicCamera();
    camera.setToOrtho(false, mapWidth, mapHeight);
    camera.update();

    // ecs
    engine = new PooledEngine();
    engine.addSystem(new WaveSystem(level));
    engine.addSystem(new SpawnSystem(engine, mapHeight, 5.5f));
    engine.addSystem(turretSystem = new TurretSystem());
    engine.addSystem(pathFindingSystem = new PathFindingSystem(mapHeight, mapWidth, map));
    engine.addSystem(new MoveToSystem());
    engine.addSystem(new MovementSystem());
    engine.addSystem(new RenderSystem(camera, tilewidth));

    loadSprites();
    setupEntities();

    pathFindingSystem.init(new Vector2(39.5f, mapHeight - 10 + 0.5f));
}
 
開發者ID:MiniDigger,項目名稱:projecttd,代碼行數:45,代碼來源:GameScreen.java


注:本文中的com.badlogic.gdx.graphics.OrthographicCamera.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。