So I’m using a viewport to stretch the game to fit into any android device, but now I can’t seem to move the camera at all. The camera’s width is 640 and the height is 480. For some reason the bottom left corner of the camera is stuck at -640 and I cannot figure out how to move it from there. Setting the camera’s position to anything will not move it at all. So pretty much I have a background the same size as the camera, the bottom left point of the background is positioned at {0, 0} but that happens to be the center of my camera that I can’t seem to move.
public void show() {
//Technical Stuff
cam = new OrthographicCamera(640, 480);
cam.setToOrtho(true, 640, 480);
viewport = new StretchViewport(640, 480, cam);
viewport.setScreenX(640);
viewport.setScreenY(480);
viewport.apply(true);
cam.position.set(640, 480, 0);
// Technical Graphical Stuff
batch = new SpriteBatch();
BackGroundTexture = new Texture(Gdx.files.internal("data/BackGround.png"));
//World Graphics Stuff
starField = new StarField();
}
@Override
public void render(float delta) {
update(delta);
cam.update();
batch.setProjectionMatrix(cam.projection);
batch.begin();
batch.draw(BackGroundTexture, 0, 0);
starField.render(batch);
batch.end();
}
public void update(float delta){
}
@Override
public void resize(int width, int height) {
viewport.update(width, height);
}
P.S. It scaled correctly, so at least that’s working. Hopefullying this can be fixed or else I’m going to have to start using whacky coordinates.