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

The following examples show how to use com.badlogic.gdx.graphics.OrthographicCamera#setToOrtho() . 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: AzurLaneSpineCharacterDecoder.java    From AzurLaneSpineCharacterDecoder with MIT License 6 votes vote down vote up
@Override
public void create() {
	batch = new SpriteBatch();
	img = new Texture("core/assets/WatchDog.png");
	camera = new OrthographicCamera();
	camera.setToOrtho(false);

	spineKeeperArray = new Array<PerSpineKeeper>();
	if (jsonType) {
		JsonReader reader = new JsonReader();
		JsonValue jsonValue = reader.parse(Gdx.files.absolute(args.get(0)));
		System.out.println();
		array = jsonValue.asStringArray();
		size = array.length;
	}
	path = System.getProperty("user.dir");

	scale=Float.parseFloat(Gdx.files.internal("core/assets/scale.txt").readString());
}
 
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: ClientDiscoveryScreen.java    From killingspree with MIT License 6 votes vote down vote up
@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;
}
 
Example 4
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 5
Source File: AbstractScreen.java    From Unlucky with MIT License 5 votes vote down vote up
public AbstractScreen(final Unlucky game, final ResourceManager rm) {
    this.game = game;
    this.rm = rm;

    cam = new OrthographicCamera(Unlucky.V_WIDTH, Unlucky.V_HEIGHT);
    cam.setToOrtho(false);
    // the game will retain it's scaled dimensions regardless of resizing
    viewport = new StretchViewport(Unlucky.V_WIDTH, Unlucky.V_HEIGHT, cam);

    stage = new Stage(viewport, game.batch);
}
 
Example 6
Source File: Box2DDebugger.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() {
  setEnabled(false);
  renderer = new Box2DDebugRenderer();
  camera = new OrthographicCamera();
  camera.setToOrtho(true);
  camera.near = -1024;
  camera.far  =  1024;
  camera.rotate(Vector3.X, -60);
  camera.rotate(Vector3.Z, -45);
}
 
Example 7
Source File: MainMenuScreen.java    From killingspree with MIT License 5 votes vote down vote up
@Override
public void show() {
    font = game.getFont(170);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
    buttons = new ArrayList<MyButton>();
    addAllButtons();
    final Preferences prefs = Gdx.app.getPreferences("profile");
    String name = prefs.getString("name");
    name = name.trim();
    if (name.length() == 0) {
        Gdx.input.getTextInput(new TextInputListener() {
            
            @Override
            public void input(String text) {
                prefs.putString("name", text);
                prefs.flush();
            }
            
            @Override
            public void canceled() {
            }
        }, "Enter name", "");
    }
}
 
Example 8
Source File: LobbyScreen.java    From killingspree with MIT License 5 votes vote down vote up
@Override
public void show() {
    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>();
    isServer = false;
    ipAddresses = new ArrayList<String>();
    markForDispose = false;
    startGame = false;
    host = "127.0.0.1";
}
 
Example 9
Source File: OptionsScreen.java    From killingspree with MIT License 5 votes vote down vote up
@Override
public void show() {
    font = game.getFont(170);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
    buttons = new ArrayList<MyButton>();
    addAllButtons();
    buttonPressed = false;
}
 
Example 10
Source File: BattleScreen.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void initializeVariables() {
	players = new ArrayList<TeamLeader>();
	playerSortedUnits = Player.getInstance().getUnitsSortedByIni();
	mapCamera = new OrthographicCamera();
	mapCamera.setToOrtho(false, VISIBLE_WIDTH, VISIBLE_HEIGHT);
	isPaused = false;
}
 
Example 11
Source File: SplashScreen.java    From killingspree with MIT License 5 votes vote down vote up
@Override
public void show() {
    font = game.getFont(200);
    batch = new SpriteBatch();
    camera = new OrthographicCamera();
    viewport = new FitViewport(1280, 720, camera);
    camera.setToOrtho(false, 1280, 720);
}
 
Example 12
Source File: Raycaster.java    From raycaster with MIT License 5 votes vote down vote up
@Override
public void create () {
   // Setup 2d camera with top left coordinates
   // http://stackoverflow.com/questions/7708379/changing-the-coordinate-system-in-libgdx-java/7751183#7751183
   // This forces us to flip textures on the y axis, eg. in Camera#drawSky
   orthoCamera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
   orthoCamera.setToOrtho(true, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
   
   this.player = new Player(15.3, -1.2, Math.PI * 0.3);
   this.map = new Map(32);
   this.controls = new Controls();
   this.camera = new Camera(orthoCamera, 320, Math.PI * 0.4);

   this.map.randomize();
}
 
Example 13
Source File: GameScreen.java    From FruitCatcher with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {    	
       imageProvider = game.getImageProvider();
       soundManager = game.getSoundManager();
   	
       camera = new OrthographicCamera();
       camera.setToOrtho(false, imageProvider.getScreenWidth(), 
       						 imageProvider.getScreenHeight());
       batch = new SpriteBatch();
       
       basketRegion = imageProvider.getBasket();
       basket = new Basket(imageProvider.getScreenWidth(), st.basketX);

       fallingObjectFactory = new FallingObjectFactory(imageProvider);
       
       timesTwoAnimations = new Array<TimesTwoAnimation>();
       
       clock = new AnalogueClock(imageProvider);
       
       numberBoard = new NumberBoard(imageProvider);
       
       backButton = new Button(imageProvider.getBack());
       backButton.setPos(10, 10);
       
       pauseTexture = imageProvider.getPause();
       pauseX = (imageProvider.getScreenWidth() - pauseTexture.getRegionWidth())/2;
       pauseY = (imageProvider.getScreenHeight() - pauseTexture.getRegionHeight())/2;
       
       initGame();        
       
       Gdx.input.setInputProcessor(this);
       Gdx.input.setCatchBackKey(true);
}
 
Example 14
Source File: SceneList.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private TextureRegion createBgIcon(String atlas, String region) {
	TextureAtlas a = new TextureAtlas(
			Gdx.files.absolute(Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/1/" + atlas + ".atlas"));
	AtlasRegion r = a.findRegion(region);

	if (r == null) {
		a.dispose();
		return null;
	}

	GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(200,
			(int) (r.getRegionHeight() * 200f / r.getRegionWidth()));

	frameBufferBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE);
	FrameBuffer fbo = frameBufferBuilder.build();

	SpriteBatch fboBatch = new SpriteBatch();
	fboBatch.setColor(Color.WHITE);
	OrthographicCamera camera = new OrthographicCamera();
	camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
	fboBatch.setProjectionMatrix(camera.combined);

	Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
	fbo.begin();
	fboBatch.begin();
	fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
	fboBatch.end();

	TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
	// tex.flip(false, true);

	fbo.end();
	Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

	fbo.dispose();
	a.dispose();
	fboBatch.dispose();

	return tex;
}
 
Example 15
Source File: HelpScreen.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public HelpScreen (SuperJumper game) {
	this.game = game;
	guiCam = new OrthographicCamera();
	guiCam.setToOrtho(false, 320, 480);
	nextBounds = new Rectangle(320 - 64, 0, 64, 64);
	touchPoint = new Vector3();
	helpImage = Assets.loadTexture("data/help1.png");
	helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}
 
Example 16
Source File: VfxFrameBuffer.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
public void initialize(int width, int height) {
    if (initialized) { dispose(); }

    initialized = true;

    int boundFboHandle = getBoundFboHandle();
    fbo = new FrameBuffer(pixelFormat, width, height, false);
    fbo.getColorBufferTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
    Gdx.gl20.glBindFramebuffer(GL20.GL_FRAMEBUFFER, boundFboHandle);

    OrthographicCamera cam = tmpCam;
    cam.setToOrtho(false, width, height);
    localProjection.set(cam.combined);
    localTransform.set(zeroTransform);
}
 
Example 17
Source File: BattleScreen.java    From Norii with Apache License 2.0 4 votes vote down vote up
private void initializeHUD() {
	hudCamera = new OrthographicCamera();
	hudCamera.setToOrtho(false, VIEWPORT.physicalWidth, VIEWPORT.physicalHeight);
	playerBattleHUD = new PlayerBattleHUD(hudCamera, Utility.sortUnits(allUnits));
}
 
Example 18
Source File: DemoCamera.java    From ud405 with MIT License 4 votes vote down vote up
public DemoCamera() {
    overviewCamera = new OrthographicCamera();
    closeupCamera = new OrthographicCamera();
    closeupCamera.setToOrtho(false, Gdx.graphics.getWidth() * INITIAL_ZOOM, Gdx.graphics.getHeight() * INITIAL_ZOOM);
    overviewCamera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
 
Example 19
Source File: NahwcGame.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
private void init () {
	savedStuff = new SavedStuff();
	savedStuff.loadPreferencesAndScore();
	
	levelNumber = savedStuff.getLevelNumber();
	isFaster = savedStuff.isFaster();
	isColor = savedStuff.isColor();
	isAnimate = savedStuff.isAnimate();
	isSound = savedStuff.isSound();
	isOutline = savedStuff.isOutline();
	isPermOutline = savedStuff.isPermOutline();
	decreaseSpeed = savedStuff.getDecreaseSpeed();
	timeToUpdate = savedStuff.getTimeToUpdate();
	levelNumber = savedStuff.getLevelNumber();
	hiScore = savedStuff.getHiScore();
	
	// Loads level based on selected level
	level = new Level(levelNumber);
	level.loadLevel();
	startX = level.getStartCoords().x;
	startY = level.getStartCoords().y;
	
	bounds = new Rectangle(startX, startY, Level.SIZE, Level.SIZE);
	worm = new Worm(bounds, WORM_LENGTH);
	cam = new OrthographicCamera();
	cam.setToOrtho(false, SCREEN_WIDTH_PX, SCREEN_HEIGHT_PX);
	food = new Food();
	renderer = new Renderer(cam, worm, food, level);
	testRect = new Rectangle(0, 0, Level.SIZE, Level.SIZE);
	rnd = new Random();

	collision = new CheckCollision(food, worm, level);
	musicPlayer = new MyMusic();
	for (int i = 0; i < NUMBER_OF_FOOD; i++) {
		makeInitialFood();
	}
	renderer.init();
	controller = new Controller(worm);
	if (isPermOutline) {
		renderer.changeOutline();
	}
}
 
Example 20
Source File: WinScreen.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public WinScreen(SuperJumper game) {
	this.game = game;
	cam = new OrthographicCamera();
	cam.setToOrtho(false, 320, 480);
	princess = new TextureRegion(Assets.arrow.getTexture(), 210, 122, -40, 38);
}