Example usage for com.badlogic.gdx.graphics Camera project

List of usage examples for com.badlogic.gdx.graphics Camera project

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Camera project.

Prototype

public Vector3 project(Vector3 worldCoords) 

Source Link

Document

Projects the Vector3 given in world space to screen coordinates.

Usage

From source file:com.nebula2d.editor.framework.GameObject.java

License:Open Source License

public boolean isSelected(Camera cam, float x, float y) {
    if (renderer != null && renderer.isReady() && renderer.getBoundingBox(cam).contains(x, y))
        return true;

    OrthographicCamera ortho = (OrthographicCamera) cam;

    Vector3 proj = cam.project(new Vector3(pos.x, pos.y, 0));
    System.out.println(ortho.zoom);
    Circle point = new Circle(proj.x, proj.y, 4);
    return point.contains(x, y);
}

From source file:rosthouse.rosty.systems.debug.ShapeRenderSystem.java

private void drawEntityInformation(SpriteBatch batch, Camera camera, Entity current) {
    if (cmPosition.has(current)) {
        batch.begin();//from  w  w w .ja  va 2  s. co m
        PositionComponent cpPosition = cmPosition.get(current);
        String positonString = String.format("Pos: [%f|%f]", cpPosition.x, cpPosition.y);
        String rotationString = String.format("Rot: [%f]", (float) Math.toDegrees(cpPosition.rotation));
        StringBuilder builder = new StringBuilder();
        builder.append(positonString).append("\n").append(rotationString);
        Vector3 screenCoordinates = camera.project(new Vector3(cpPosition.x, cpPosition.y, 0));
        systemFont.draw(batch, builder.toString(), screenCoordinates.x, screenCoordinates.y);
        batch.end();
    }
}