-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameCamera.java
More file actions
23 lines (23 loc) · 829 Bytes
/
Copy pathGameCamera.java
File metadata and controls
23 lines (23 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class GameCamera {
private OrthographicCamera cam;
private StretchViewport viewport;
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();
}
public Matrix4 combined(){
return cam.combined;
}
public void update(int width , int height){
viewport.update(width , height);
}
//where is the person clicking
public Vector2 getInputInGameWorld(){
Vector3 inputScreen = new Vector3(Gdx.input.getX() ,Gdx.graphics.getHeight() - Gdx.input.getY() , 0);
Vector3 unprojected = cam.unproject(inputScreen);
return new Vector2(unprojected.x , unprojected.y);
}
}