本文整理汇总了Java中com.badlogic.gdx.graphics.OrthographicCamera.unproject方法的典型用法代码示例。如果您正苦于以下问题:Java OrthographicCamera.unproject方法的具体用法?Java OrthographicCamera.unproject怎么用?Java OrthographicCamera.unproject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.OrthographicCamera
的用法示例。
在下文中一共展示了OrthographicCamera.unproject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: touchInRectangle
import com.badlogic.gdx.graphics.OrthographicCamera; //导入方法依赖的package包/类
public static boolean touchInRectangle(Rectangle r, OrthographicCamera camera) {
if (Gdx.input.isTouched()) {
Vector3 touchPos = new Vector3();
touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
camera.unproject(touchPos);
return r.x <= touchPos.x && r.x + r.width >= touchPos.x
&& r.y <= touchPos.y && r.y + r.height >= touchPos.y;
}
return false;
}
示例2: unprojectWorld
import com.badlogic.gdx.graphics.OrthographicCamera; //导入方法依赖的package包/类
/**
* Translates a point from screen coordinates to world coordinates.<br>
* This method returns an internally cached vector instance, do not store this instance!
*
* @param x the x position of the point
* @param y the y position of the point
*
* @return the point position in world coordinates.
*/
public static Vector2 unprojectWorld(float x, float y) {
v3.set(x, y, 0);
OrthographicCamera camera = GameManager.getWorldCamera();
camera.unproject(v3);
v2.set(v3.x, v3.y);
return v2;
}
示例3: unprojectGui
import com.badlogic.gdx.graphics.OrthographicCamera; //导入方法依赖的package包/类
/**
* Translate a point from screen coordinates to gui coordinates.<br>
* This method returns an internally cached vector instance, do not store this instance!
*
* @param x the x position of the point
* @param y the y position of the point
*
* @return the point position in world coordinates.
*/
public static Vector2 unprojectGui(float x, float y) {
v3.set(x, y, 0);
OrthographicCamera camera = GameManager.getGuiCamera();
camera.unproject(v3);
v2.set(v3.x, v3.y);
return v2;
}