本文整理汇总了Java中org.andengine.engine.camera.Camera.getSurfaceHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.getSurfaceHeight方法的具体用法?Java Camera.getSurfaceHeight怎么用?Java Camera.getSurfaceHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.engine.camera.Camera
的用法示例。
在下文中一共展示了Camera.getSurfaceHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clipForCamera
import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
/**
* Perform clipping using normal Scene coordinate transformations
* @param pGLState
* @param pCamera
*/
private void clipForCamera(GLState pGLState, Camera pCamera) {
final int surfaceHeight = pCamera.getSurfaceHeight();
/* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */
/* Determine clipping coordinates of each corner in surface coordinates. */
final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0, new float[2]));
final int lowerLeftX = (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerLeftY = surfaceHeight - (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight, new float[2]));
final int upperLeftX = (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperLeftY = surfaceHeight - (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight, new float[2]));
final int upperRightX = (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperRightY = surfaceHeight - (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0, new float[2]));
final int lowerRightX = (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerRightY = surfaceHeight - (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
/* Determine minimum and maximum x clipping coordinates. */
final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
/* Determine minimum and maximum y clipping coordinates. */
final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
/* Determine clipping width and height. */
final int clippingWidth = maxClippingX - minClippingX;
final int clippingHeight = maxClippingY - minClippingY;
//Debug.d("ClippingY: min="+minClippingY+", max="+maxClippingY);
//Debug.d("clipForCamera: GLES20.glScissor("+minClippingX+", "+minClippingY+", "+clippingWidth+", "+clippingHeight+")");
GLES20.glScissor(minClippingX, minClippingY, clippingWidth, clippingHeight);
}
示例2: clipForHUD
import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
/**
* Perform clipping using HUD coordinate transformations
* @param pGLState
* @param pCamera
*/
private void clipForHUD(GLState pGLState, Camera pCamera) {
float[] coordinates = this.getParent().convertLocalCoordinatesToSceneCoordinates(this.mX, this.mY, new float[2]);
float[] size = this.getParent().convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight, new float[2]);
final float zoom = ((ZoomCamera)pCamera).getZoomFactor();
final float screenRatioX = pCamera.getSurfaceWidth()/pCamera.getWidth();
final float screenRatioY = pCamera.getSurfaceHeight()/pCamera.getHeight();
final float left = (this.mX - (this.mWidth/2)) * screenRatioX / zoom;
final float bottom = (this.mY - (this.mHeight/2)) * screenRatioY / zoom;
final float width = this.mWidth * screenRatioX / zoom;
final float height = this.mHeight * screenRatioY / zoom;
if (print_debug) {
Debug.d("Scrollable X: " + this.mX);
Debug.d("Scrollable Y: " + this.mY);
Debug.d("Scrollable W: " + this.mWidth);
Debug.d("Scrollable H: " + this.mHeight);
Debug.d("Scrollable x,y: "+coordinates[Constants.VERTEX_INDEX_X]+","+coordinates[Constants.VERTEX_INDEX_Y]);
Debug.d("Scrollable w,h: " + size[Constants.VERTEX_INDEX_X]+","+size[Constants.VERTEX_INDEX_Y]);
Debug.d("clipForHUD: GLES20.glScissor("+left+", "+bottom+", "+width+", "+height+")");
Debug.d("Scrollable camera zoom: " + zoom);
Debug.d("Scrollable screenRatioX: " + pCamera.getSurfaceWidth()/pCamera.getWidth());
Debug.d("Scrollable screenRatioY: " + pCamera.getSurfaceHeight()/pCamera.getHeight());
print_debug = false;
}
GLES20.glScissor((int)left, (int)bottom, (int)width, (int)height);
// Math.round(((clipX + point.x)) * screenRatioX),
// Math.round((cameraH - ((clipY + point.y) + clipH)) * screenRatioY),
// Math.round(clipW * screenRatioX),
// Math.round(clipH * screenRatioY));
}
示例3: clipToProgress
import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
private void clipToProgress(GLState pGLState, Camera pCamera) {
final float zoom = ((ZoomCamera)pCamera).getZoomFactor();
final float screenRatioX = pCamera.getSurfaceWidth()/pCamera.getWidth();
final float screenRatioY = pCamera.getSurfaceHeight()/pCamera.getHeight();
final float left = (this.mX - (this.mWidth/2)) * screenRatioX / zoom;
final float bottom = (this.mY - (this.mHeight/2)) * screenRatioY / zoom;
final float width = (this.mWidth * screenRatioX / zoom) * this.progress;
final float height = this.mHeight * screenRatioY / zoom;
GLES20.glScissor((int) left, (int) bottom, (int) width, (int) height);
}
示例4: onManagedDraw
import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
if (this.mClippingEnabled) {
/* Enable scissor test, while remembering previous state. */
final boolean wasScissorTestEnabled = pGLState.enableScissorTest();
final int surfaceHeight = pCamera.getSurfaceHeight();
/* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */
/* Determine clipping coordinates of each corner in surface coordinates. */
final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0));
final int lowerLeftX = (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerLeftY = surfaceHeight - (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight));
final int upperLeftX = (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperLeftY = surfaceHeight - (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight));
final int upperRightX = (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperRightY = surfaceHeight - (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0));
final int lowerRightX = (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerRightY = surfaceHeight - (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
/* Determine minimum and maximum x clipping coordinates. */
final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
/* Determine minimum and maximum y clipping coordinates. */
final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
/* Determine clipping width and height. */
final int clippingWidth = maxClippingX - minClippingX;
final int clippingHeight = maxClippingY - minClippingY;
/* Finally apply the clipping. */
pGLState.glPushScissor(minClippingX, minClippingY, clippingWidth, clippingHeight);
/* Draw children, etc... */
super.onManagedDraw(pGLState, pCamera);
/* Revert scissor test to previous state. */
pGLState.glPopScissor();
pGLState.setScissorTestEnabled(wasScissorTestEnabled);
} else {
super.onManagedDraw(pGLState, pCamera);
}
}