java - libGDX how do you draw on the top left corner of the screen when you are using a viewport and moving the camera -
public orthographiccamera camera; viewport viewport; camera = new orthographiccamera(); viewport = new scalingviewport(scaling.stretch, 1920, 1080, camera); viewport.apply(); camera.position.set(camera.viewportwidth / 2, camera.viewportheight / 2, 0); camera.update();
then move camera mouse code
vector3 v = new vector3(gdx.input.getx(), gdx.input.gety(), 0); camera.unproject(v); camera.position.set(v); camera.update();
everything works fine except have text want draw on top left corner of screen. use camera.combined , draws on original screen doesn't follow move camera. how accomplish this?
excellent question, created method return vector3 relative screen position. i'm not sure if there built in way or easier way here code below. luck on program me.
public vector3 relativevector(float x, float y,orthographiccamera c){ return new vector3(x+c.position.x-c.viewportwidth/2,y+c.position.y-c.viewportheight/2,0); }
Comments
Post a Comment