0

Anyone know if it's possible to set the upper left corner of the Android device as 0,0? As of now, it seems the location is (on my HTC desire) X: 320, Y: 0. I want it to be 0,0.

Anyone know if it's possible? Or how to. As I'm placing a lot of tiles, that later will also use the X and Y positions, I find it favorable that the top left corner is 0,0.

LG87
  • 695
  • 1
  • 10
  • 20

1 Answers1

1

You need to look into using cameras.

OrthographicCamera camera;
camera = new OrthographicCamera((float) 100, (100 * (9.0f/16.0f) ));    //UI
camera.position.set(0f, 0f, 0);

I typically store that camera somewhere, and then you need to apply it to the spritebatch each time your render loops.

applyCamera(spriteBatch, camera);
GfxD.spriteBatch.begin();{
    for(Sprite4 sprite: SpriteList) {   sprite.draw(spriteBatch);   }
}GfxD.spriteBatch.end();

...and my "apply camera" method looks like...

public static void applyCamera  (SpriteBatch spritebatch, OrthographicCamera camera){
    camera.update();
    spritebatch.getProjectionMatrix().set(camera.combined);
}

You will have to edit the code for your own purposes, but hopefully that should get you started in the right direction.

Psyfire
  • 26
  • 1
  • It seems like overkill for the problem I'm working with. As I'm just going to have the app landscaped all the time, adding even more stuff that needs to run at each render seems like a resource kill.. But, I will take a look at it, thanks :) – LG87 May 10 '12 at 01:14