本文整理汇总了Java中org.andengine.util.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.andengine.util包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAreaTouched
import org.andengine.util.Constants; //导入依赖的package包/类
@Override
public boolean onAreaTouched(TouchEvent touchEvent, float localTouchX, float localTouchY) {
final float sceneTouchX = touchEvent.getX();
final float sceneTouchY = touchEvent.getY();
for (ITouchArea area: this.touchAreas) {
if (area.contains(sceneTouchX, sceneTouchY)) {
final float[] areaTouchCoordinates = area.convertSceneCoordinatesToLocalCoordinates(sceneTouchX, sceneTouchY);
final float areaTouchX = areaTouchCoordinates[Constants.VERTEX_INDEX_X];
final float areaTouchY = areaTouchCoordinates[Constants.VERTEX_INDEX_Y];
final Boolean handled = area.onAreaTouched(touchEvent, areaTouchX, areaTouchY);
if (handled != null && handled) {
return true;
}
}
}
return true;
}
示例2: checkContains
import org.andengine.util.Constants; //导入依赖的package包/类
public static boolean checkContains(final float pX1, final float pY1, final float pX2, final float pY2, final float pX3, final float pY3, final Transformation pTransformation, final float pX, final float pY) {
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[0 + Constants.VERTEX_INDEX_X] = pX1;
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[0 + Constants.VERTEX_INDEX_Y] = pY1;
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[2 + Constants.VERTEX_INDEX_X] = pX2;
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[2 + Constants.VERTEX_INDEX_Y] = pY2;
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[4 + Constants.VERTEX_INDEX_X] = pX3;
TriangleCollisionChecker.VERTICES_CONTAINS_TMP[4 + Constants.VERTEX_INDEX_Y] = pY3;
pTransformation.transform(TriangleCollisionChecker.VERTICES_CONTAINS_TMP);
final float x1 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[0 + Constants.VERTEX_INDEX_X];
final float y1 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[0 + Constants.VERTEX_INDEX_Y];
final float x2 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[2 + Constants.VERTEX_INDEX_X];
final float y2 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[2 + Constants.VERTEX_INDEX_Y];
final float x3 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[4 + Constants.VERTEX_INDEX_X];
final float y3 = TriangleCollisionChecker.VERTICES_CONTAINS_TMP[4 + Constants.VERTEX_INDEX_Y];
return TriangleCollisionChecker.checkContains(x1, y1, x2, y2, x3, y3, pX, pY);
}
示例3: convertSurfaceTouchEventToSceneTouchEvent
import org.andengine.util.Constants; //导入依赖的package包/类
public void convertSurfaceTouchEventToSceneTouchEvent(final TouchEvent pSurfaceTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) {
final float relativeX;
final float relativeY;
final float surfaceTouchEventX = pSurfaceTouchEvent.getX();
final float surfaceTouchEventY = pSurfaceTouchEvent.getY();
final float rotation = this.mRotation;
if (rotation == 0) {
relativeX = surfaceTouchEventX / pSurfaceWidth;
relativeY = 1 - (surfaceTouchEventY / pSurfaceHeight);
} else if (rotation == 180) {
relativeX = 1 - (surfaceTouchEventX / pSurfaceWidth);
relativeY = surfaceTouchEventY / pSurfaceHeight;
} else {
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = surfaceTouchEventX;
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = surfaceTouchEventY;
MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); // TODO Use a Transformation object instead!?!
relativeX = Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] / pSurfaceWidth;
relativeY = 1 - (Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] / pSurfaceHeight);
}
this.convertAxisAlignedSurfaceTouchEventToSceneTouchEvent(pSurfaceTouchEvent, relativeX, relativeY);
}
示例4: getSceneCoordinatesFromSurfaceCoordinates
import org.andengine.util.Constants; //导入依赖的package包/类
public float[] getSceneCoordinatesFromSurfaceCoordinates(final float[] pSurfaceCoordinates, final int pSurfaceWidth, final int pSurfaceHeight) {
final float relativeX;
final float relativeY;
final float rotation = this.mRotation;
if (rotation == 0) {
relativeX = pSurfaceCoordinates[Constants.VERTEX_INDEX_X] / pSurfaceWidth;
relativeY = 1 - (pSurfaceCoordinates[Constants.VERTEX_INDEX_Y] / pSurfaceHeight);
} else if (rotation == 180) {
relativeX = 1 - (pSurfaceCoordinates[Constants.VERTEX_INDEX_X] / pSurfaceWidth);
relativeY = pSurfaceCoordinates[Constants.VERTEX_INDEX_Y] / pSurfaceHeight;
} else {
MathUtils.rotateAroundCenter(pSurfaceCoordinates, rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); // TODO Use a Transformation object instead!?!
relativeX = pSurfaceCoordinates[Constants.VERTEX_INDEX_X] / pSurfaceWidth;
relativeY = 1 - (pSurfaceCoordinates[Constants.VERTEX_INDEX_Y] / pSurfaceHeight);
}
this.convertAxisAlignedSurfaceCoordinatesToSceneCoordinates(pSurfaceCoordinates, relativeX, relativeY);
return pSurfaceCoordinates;
}
示例5: convertSceneTouchEventToSurfaceTouchEvent
import org.andengine.util.Constants; //导入依赖的package包/类
public void convertSceneTouchEventToSurfaceTouchEvent(final TouchEvent pSceneTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) {
this.convertAxisAlignedSceneToSurfaceTouchEvent(pSceneTouchEvent, pSurfaceWidth, pSurfaceHeight);
final float rotation = this.mRotation;
if (rotation == 0) {
/* Nothing. */
} else if (rotation == 180) {
pSceneTouchEvent.setY(pSurfaceHeight - pSceneTouchEvent.getY());
pSceneTouchEvent.setX(pSurfaceWidth - pSceneTouchEvent.getX());
} else {
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX();
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY();
MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, -rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); // TODO Use a Transformation object instead!?!
pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]);
}
}
示例6: fillVertices
import org.andengine.util.Constants; //导入依赖的package包/类
public static void fillVertices(final float pLocalX, final float pLocalY, final float pLocalWidth, final float pLocalHeight, final Transformation pLocalToSceneTransformation, final float[] pVertices) {
final float localXMin = pLocalX;
final float localXMax = pLocalX + pLocalWidth;
final float localYMin = pLocalY;
final float localYMax = pLocalY + pLocalHeight;
pVertices[0 + Constants.VERTEX_INDEX_X] = localXMin;
pVertices[0 + Constants.VERTEX_INDEX_Y] = localYMin;
pVertices[2 + Constants.VERTEX_INDEX_X] = localXMax;
pVertices[2 + Constants.VERTEX_INDEX_Y] = localYMin;
pVertices[4 + Constants.VERTEX_INDEX_X] = localXMax;
pVertices[4 + Constants.VERTEX_INDEX_Y] = localYMax;
pVertices[6 + Constants.VERTEX_INDEX_X] = localXMin;
pVertices[6 + Constants.VERTEX_INDEX_Y] = localYMax;
pLocalToSceneTransformation.transform(pVertices);
}
示例7: convertSurfaceToSceneTouchEvent
import org.andengine.util.Constants; //导入依赖的package包/类
public void convertSurfaceToSceneTouchEvent(final TouchEvent pSurfaceTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) {
final float relativeX;
final float relativeY;
final float surfaceTouchEventX = pSurfaceTouchEvent.getX();
final float surfaceTouchEventY = pSurfaceTouchEvent.getY();
final float rotation = this.mRotation;
if(rotation == 0) {
relativeX = surfaceTouchEventX / pSurfaceWidth;
relativeY = surfaceTouchEventY / pSurfaceHeight;
} else if(rotation == 180) {
relativeX = 1 - (surfaceTouchEventX / pSurfaceWidth);
relativeY = 1 - (surfaceTouchEventY / pSurfaceHeight);
} else {
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = surfaceTouchEventX;
Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = surfaceTouchEventY;
MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1);
relativeX = Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] / pSurfaceWidth;
relativeY = Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] / pSurfaceHeight;
}
this.convertAxisAlignedSurfaceToSceneTouchEvent(pSurfaceTouchEvent, relativeX, relativeY);
}
示例8: onAreaTouched
import org.andengine.util.Constants; //导入依赖的package包/类
@Override
public boolean onAreaTouched(final TouchEvent pTouchEvent, final float touchX, final float touchY) {
boolean handled = this.scrollDetector.onManagedTouchEvent(pTouchEvent);
//Debug.d("scrollDetector: "+handled);
if (this.touch_was_scroll || this.is_scrolling) {
//Debug.d("Touch was scroll ");
this.touch_was_scroll = false;
this.scroll_last = System.currentTimeMillis();
return true;
} else {
//Debug.d("Touch was not scroll ");
this.touch_was_scroll = false;
long delay = System.currentTimeMillis() - this.scroll_last;
if (delay < this.scroll_timeout) {
return false;
}
final float sceneTouchX = pTouchEvent.getX();
final float sceneTouchY = pTouchEvent.getY();
for (ITouchArea area: this.touchAreas) {
if (area.contains(sceneTouchX, sceneTouchY)) {
final float[] areaTouchCoordinates = area.convertSceneCoordinatesToLocalCoordinates(sceneTouchX, sceneTouchY);
final float areaTouchX = areaTouchCoordinates[Constants.VERTEX_INDEX_X];
final float areaTouchY = areaTouchCoordinates[Constants.VERTEX_INDEX_Y];
final Boolean ishandled = area.onAreaTouched(pTouchEvent, areaTouchX, areaTouchY);
if (ishandled != null && ishandled) {
return true;
}
}
}
return false;
}
}
示例9: clipForCamera
import org.andengine.util.Constants; //导入依赖的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);
}
示例10: clipForHUD
import org.andengine.util.Constants; //导入依赖的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));
}
示例11: spawnParticle
import org.andengine.util.Constants; //导入依赖的package包/类
private void spawnParticle() {
if (this.mParticlesAlive < this.mParticlesMaximum) {
Particle<T> particle = this.mParticles[this.mParticlesAlive];
/* New particle needs to be created. */
this.mParticleEmitter.getPositionOffset(ParticleSystem.POSITION_OFFSET_CONTAINER);
final float x = ParticleSystem.POSITION_OFFSET_CONTAINER[Constants.VERTEX_INDEX_X];
final float y = ParticleSystem.POSITION_OFFSET_CONTAINER[Constants.VERTEX_INDEX_Y];
if (particle == null) {
particle = new Particle<T>();
this.mParticles[this.mParticlesAlive] = particle;
particle.setEntity(this.mEntityFactory.create(x, y));
} else {
particle.reset();
particle.getEntity().setPosition(x, y);
}
/* Apply particle initializers. */
{
for (int i = this.mParticleInitializers.size() - 1; i >= 0; i--) {
this.mParticleInitializers.get(i).onInitializeParticle(particle);
}
for (int i = this.mParticleModifiers.size() - 1; i >= 0; i--) {
this.mParticleModifiers.get(i).onInitializeParticle(particle);
}
}
this.mParticlesAlive++;
}
}
示例12: onAreaTouchEvent
import org.andengine.util.Constants; //导入依赖的package包/类
private Boolean onAreaTouchEvent(final TouchEvent pSceneTouchEvent, final float sceneTouchEventX, final float sceneTouchEventY, final ITouchArea touchArea) {
final float[] touchAreaLocalCoordinates = touchArea.convertSceneCoordinatesToLocalCoordinates(sceneTouchEventX, sceneTouchEventY);
final float touchAreaLocalX = touchAreaLocalCoordinates[Constants.VERTEX_INDEX_X];
final float touchAreaLocalY = touchAreaLocalCoordinates[Constants.VERTEX_INDEX_Y];
final boolean handledSelf = touchArea.onAreaTouched(pSceneTouchEvent, touchAreaLocalX, touchAreaLocalY);
if (handledSelf) {
return Boolean.TRUE;
} else if (this.mOnAreaTouchListener != null) {
return this.mOnAreaTouchListener.onAreaTouched(pSceneTouchEvent, touchArea, touchAreaLocalX, touchAreaLocalY);
} else {
return null;
}
}
示例13: convertParentCoordinatesToLocalCoordinates
import org.andengine.util.Constants; //导入依赖的package包/类
@Override
public float[] convertParentCoordinatesToLocalCoordinates(final float pX, final float pY, final float[] pReuse) {
pReuse[Constants.VERTEX_INDEX_X] = pX;
pReuse[Constants.VERTEX_INDEX_Y] = pY;
this.getParentToLocalTransformation().transform(pReuse);
return pReuse;
}
示例14: convertLocalCoordinatesToSceneCoordinates
import org.andengine.util.Constants; //导入依赖的package包/类
@Override
public float[] convertLocalCoordinatesToSceneCoordinates(final float pX, final float pY, final float[] pReuse) {
final Transformation localToSceneTransformation = this.getLocalToSceneTransformation();
pReuse[Constants.VERTEX_INDEX_X] = pX;
pReuse[Constants.VERTEX_INDEX_Y] = pY;
localToSceneTransformation.transform(pReuse);
return pReuse;
}
示例15: convertSceneCoordinatesToLocalCoordinates
import org.andengine.util.Constants; //导入依赖的package包/类
@Override
public float[] convertSceneCoordinatesToLocalCoordinates(final float pX, final float pY, final float[] pReuse) {
pReuse[Constants.VERTEX_INDEX_X] = pX;
pReuse[Constants.VERTEX_INDEX_Y] = pY;
this.getSceneToLocalTransformation().transform(pReuse);
return pReuse;
}