Java Code Examples for com.badlogic.gdx.graphics.OrthographicCamera#update()

The following examples show how to use com.badlogic.gdx.graphics.OrthographicCamera#update() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfilerSystem.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
protected void initialize() {
  camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  camera.setToOrtho(false);
  camera.update();
  renderer = new ShapeRenderer();
  stage = new Stage();
  stage.getBatch().setProjectionMatrix(camera.combined);
  skin = new Skin(Gdx.files.internal("profiler/uiskin.json"));

  // setup some static config like colors etc
  SystemProfilerGUI.GRAPH_H_LINE.set(Color.ORANGE);
  gui = new SystemProfilerGUI(skin, "default");
  gui.setResizeBorder(8);
  gui.show(stage);
  world.inject(gui, true);
  gui.initialize();
}
 
Example 2
Source File: ExampleSystem.java    From libgdx-artemis-quickstart with MIT License 6 votes vote down vote up
@Override
protected void initialize() {
    super.initialize();

    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.update();

    batch = new SpriteBatch(100);

    // create some sprites to look at!
    texture = new Texture("dancingman.png");
    for (int i = 0; i < 40; i++) {
        E.E()
                .example()
                .translationX(MathUtils.random(-texture.getWidth(), Gdx.graphics.getWidth()))
                .translationY(MathUtils.random(0, Gdx.graphics.getHeight()))
                .exampleAge(MathUtils.random(10f));
    }
}
 
Example 3
Source File: GameCamera.java    From libgdx-2d-tutorial with MIT License 5 votes vote down vote up
public GameCamera (int width, int height) {
	cam = new OrthographicCamera();
	viewport = new StretchViewport(width, height, cam);
	viewport.apply();
	cam.position.set(width / 2, height / 2, 0);
	cam.update();
}
 
Example 4
Source File: LoadingGameScreen.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void show () {
	camera = new OrthographicCamera();
	camera.position.set(GdxDemo3D.WIDTH * .5f, GdxDemo3D.HEIGHT * .5f, 0);
	camera.update();
	viewport = new FitViewport(GdxDemo3D.WIDTH, GdxDemo3D.HEIGHT, camera);
	shapeRenderer = new ShapeRenderer();
}
 
Example 5
Source File: SimpleTest.java    From box2dlights with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	camera = new OrthographicCamera(48, 32);
	camera.update();
	world = new World(new Vector2(0, -10), true);
	rayHandler = new RayHandler(world);
	new PointLight(rayHandler, 32);

}
 
Example 6
Source File: Box2dLightTest.java    From box2dlights with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	MathUtils.random.setSeed(Long.MIN_VALUE);

	camera = new OrthographicCamera(viewportWidth, viewportHeight);
	camera.position.set(0, viewportHeight / 2f, 0);
	camera.update();
	
	batch = new SpriteBatch();
	font = new BitmapFont();
	font.setColor(Color.RED);
	
	textureRegion = new TextureRegion(new Texture(
			Gdx.files.internal("data/marble.png")));
	bg = new Texture(Gdx.files.internal("data/bg.png"));

	createPhysicsWorld();
	Gdx.input.setInputProcessor(this);

	normalProjection.setToOrtho2D(
			0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	/** BOX2D LIGHT STUFF BEGIN */
	RayHandler.setGammaCorrection(true);
	RayHandler.useDiffuseLight(true);
	
	rayHandler = new RayHandler(world);
	rayHandler.setAmbientLight(0f, 0f, 0f, 0.5f);
	rayHandler.setBlurNum(3);

	initPointLights();
	/** BOX2D LIGHT STUFF END */

}
 
Example 7
Source File: RenderSystemTest.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	OrthographicCamera camera = new OrthographicCamera(640, 480);
	camera.position.set(320, 240, 0);
	camera.update();

	Texture crateTexture = new Texture("assets/crate.png");
	Texture coinTexture = new Texture("assets/coin.png");

	engine = new PooledEngine();
	engine.addSystem(new RenderSystem(camera));
	engine.addSystem(new MovementSystem());

	Entity crate = engine.createEntity();
	crate.add(new PositionComponent(50, 50));
	crate.add(new VisualComponent(new TextureRegion(crateTexture)));

	engine.addEntity(crate);

	TextureRegion coinRegion = new TextureRegion(coinTexture);

	for (int i = 0; i < 100; i++) {
		Entity coin = engine.createEntity();
		coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
		coin.add(new MovementComponent(10.0f, 10.0f));
		coin.add(new VisualComponent(coinRegion));
		engine.addEntity(coin);
	}
}
 
Example 8
Source File: PlayScreen.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
@Override
public void show() {
    camera = new OrthographicCamera();
    viewport = new FitViewport(WIDTH, HEIGHT, camera);
    camera.translate(WIDTH / 2, HEIGHT / 2);
    camera.update();

    batch = new SpriteBatch();

    playerSystem = new PlayerSystem();
    ghostSystem = new GhostSystem();
    movementSystem = new MovementSystem();
    pillSystem = new PillSystem();
    animationSystem = new AnimationSystem();
    renderSystem = new RenderSystem(batch);
    stateSystem = new StateSystem();

    engine = new Engine();
    engine.addSystem(playerSystem);
    engine.addSystem(ghostSystem);
    engine.addSystem(pillSystem);
    engine.addSystem(movementSystem);
    engine.addSystem(stateSystem);
    engine.addSystem(animationSystem);
    engine.addSystem(renderSystem);

    // box2d
    world = new World(Vector2.Zero, true);
    world.setContactListener(new WorldContactListener());
    box2DDebugRenderer = new Box2DDebugRenderer();
    showBox2DDebuggerRenderer = false;

    // box2d light
    rayHandler = new RayHandler(world);
    rayHandler.setAmbientLight(ambientLight);

    // load map
    tiledMap = new TmxMapLoader().load("map/map.tmx");
    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, 1 / 16f, batch);

    new WorldBuilder(tiledMap, engine, world, rayHandler).buildAll();

    stageViewport = new FitViewport(WIDTH * 20, HEIGHT * 20);
    stage = new Stage(stageViewport, batch);

    font = new BitmapFont(Gdx.files.internal("fonts/army_stencil.fnt"));
    Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.WHITE);

    Label scoreTextLabel = new Label("SCORE", labelStyle);
    scoreTextLabel.setPosition(WIDTH * 1, HEIGHT * 19);
    stage.addActor(scoreTextLabel);

    Label hightScoreTextLabel = new Label("High Score", labelStyle);
    hightScoreTextLabel.setPosition(WIDTH * 14, HEIGHT * 19);
    stage.addActor(hightScoreTextLabel);

    scoreLabel = new Label("0", labelStyle);
    scoreLabel.setPosition(WIDTH * 1.5f, HEIGHT * 18.2f);
    stage.addActor(scoreLabel);

    highScoreLabel = new Label("0", labelStyle);
    highScoreLabel.setPosition(WIDTH * 16.5f, HEIGHT * 18.2f);
    stage.addActor(highScoreLabel);

    gameOverLabel = new Label("              - Game Over -\n Press Enter to continue", labelStyle);
    gameOverLabel.setPosition(WIDTH * 4.3f, HEIGHT * 9f);
    gameOverLabel.setVisible(false);
    stage.addActor(gameOverLabel);

    TextureAtlas textureAtlas = GameManager.instance.assetManager.get("images/actors.pack", TextureAtlas.class);
    pacmanSprite = new Sprite(new TextureRegion(textureAtlas.findRegion("Pacman"), 16, 0, 16, 16));
    pacmanSprite.setBounds(8f, 21.5f, 16 / GameManager.PPM, 16 / GameManager.PPM);

    stringBuilder = new StringBuilder();

    changeScreen = false;
}
 
Example 9
Source File: GameStage.java    From martianrun with Apache License 2.0 4 votes vote down vote up
private void setUpCamera() {
    camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0f);
    camera.update();
}
 
Example 10
Source File: GameEngine.java    From collider with Apache License 2.0 4 votes vote down vote up
public GameEngine() {
	clear();
	camera = new OrthographicCamera(SCREEN_WIDTH, SCREEN_HEIGHT);
	camera.translate(.5f*SCREEN_WIDTH, .5f*SCREEN_HEIGHT, 0);
	camera.update();
}