当前位置: 首页>>代码示例>>Java>>正文


Java Camera类代码示例

本文整理汇总了Java中org.andengine.engine.camera.Camera的典型用法代码示例。如果您正苦于以下问题:Java Camera类的具体用法?Java Camera怎么用?Java Camera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Camera类属于org.andengine.engine.camera包,在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawIsometric

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
/**
 * Call this if the map is Isometric. <br>
 * This calls the desired draw method that the user desires.
 * 
 * @param pGLState
 * @param pCamera
 */
private void drawIsometric(final GLState pGLState, final Camera pCamera) {
	if (this.DRAW_METHOD_ISOMETRIC == TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_ALL) {
		this.drawIsometricAll(pGLState, pCamera);
	} else if (this.DRAW_METHOD_ISOMETRIC == TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_CULLING_SLIM) {
		this.drawIsometricCullingLoop(pGLState, pCamera);
	} else if (this.DRAW_METHOD_ISOMETRIC == TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_CULLING_PADDING) {
		this.drawIsometricCullingLoopExtra(pGLState, pCamera);
	} else if (this.DRAW_METHOD_ISOMETRIC == TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_CULLING_TILED_SOURCE) {
		this.drawIsometricCullingTiledSource(pGLState, pCamera);
	} else {
		Log.w(TAG,
				String.format(
						"Draw method %d is currently not supported or an unknown draw method. Will use the default draw method.",
						this.DRAW_METHOD_ISOMETRIC));
		this.DRAW_METHOD_ISOMETRIC = TMXIsometricConstants.DRAW_METHOD_ISOMETRIC_ALL;
		this.drawIsometricAll(pGLState, pCamera);
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:26,代码来源:TMXLayer.java

示例2: SplashScene

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
public SplashScene(TextureManager textureManager, AssetManager assetManager, VertexBufferObjectManager vbo, Camera camera) {
    super();
    this.setBackground(new Background(new Color(100, 100, 100)));
    try {
        splashTexture = new AssetBitmapTexture(textureManager, assetManager, "textures/splash.png", TextureOptions.BILINEAR);
        splashTextureRegion = TextureRegionFactory.extractFromTexture(splashTexture);
        splashTexture.load();
        splash = new Sprite(0, 0, splashTextureRegion, vbo);

        final float scale_factor = GameActivity.CAMERA_HEIGHT / splashTextureRegion.getHeight();
        splash.setScale(scale_factor+0.1f);
        splash.setPosition((camera.getWidth()) * 0.5f, (camera.getHeight()) * 0.5f);
        this.attachChild(splash);
    } catch (final IOException e) {
        System.err.println("Error loading splash!");
        e.printStackTrace(System.err);
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:19,代码来源:SplashScene.java

示例3: onManagedDraw

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
@Override
protected void onManagedDraw(GLState pGLState, Camera pCamera) {

    if (!this.clip) {
        super.onManagedDraw(pGLState, pCamera);
        return;
    }

    final boolean wasScissorTestEnabled = pGLState.enableScissorTest();

    if (this.isInHUD) {
        this.clipForHUD(pGLState, pCamera);
    } else {
        this.clipForCamera(pGLState, pCamera);
    }

    /* Draw children, etc... */
    super.onManagedDraw(pGLState, pCamera);

    /* Revert scissor test to previous state. */
    pGLState.setScissorTestEnabled(wasScissorTestEnabled);

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:24,代码来源:Scrollable.java

示例4: onManagedDraw

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
	this.mSpriteBatch.setIndex(0);

	final Particle<UncoloredSprite>[] particles = this.mParticles;
	for (int i = this.mParticlesAlive - 1; i >= 0; i--) {
		final Sprite sprite = particles[i].getEntity();

		/* In order to support alpha changes of the sprites inside the spritebatch,
		 * we have to 'premultiply' the RGB channels of the sprite with its alpha channel. */
		final float alpha = sprite.getAlpha();
		final float colorABGRPackedInt = ColorUtils.convertRGBAToABGRPackedFloat(sprite.getRed() * alpha, sprite.getGreen() * alpha, sprite.getBlue() * alpha, alpha);

		this.mSpriteBatch.drawWithoutChecks(sprite, colorABGRPackedInt);
	}
	this.mSpriteBatch.submit();

	this.mSpriteBatch.onDraw(pGLState, pCamera);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:20,代码来源:BatchedSpriteParticleSystem.java

示例5: onManagedDraw

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
	this.mSpriteBatch.setIndex(0);

	final Particle<Entity>[] particles = this.mParticles;
	for(int i = this.mParticlesAlive - 1; i >= 0; i--) {
		final Entity entity = particles[i].getEntity();

		/* In order to support alpha changes of the sprites inside the spritebatch,
		 * we have to 'premultiply' the RGB channels of the sprite with its alpha channel. */
		final float alpha = entity.getAlpha();
		final float colorABGRPackedInt = ColorUtils.convertRGBAToABGRPackedFloat(entity.getRed() * alpha, entity.getGreen() * alpha, entity.getBlue() * alpha, alpha);

		this.mSpriteBatch.drawWithoutChecks(this.mTextureRegion, entity, this.mTextureRegion.getWidth(), this.mTextureRegion.getHeight(), colorABGRPackedInt);
	}
	this.mSpriteBatch.submit();

	this.mSpriteBatch.onDraw(pGLState, pCamera);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:20,代码来源:BatchedPseudoSpriteParticleSystem.java

示例6: draw

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
/**
 * Modified to take in account the map orientation. <br>
 * If orientation is not supported then a warning will be thrown to the log
 * and will call {@link #drawOrthogonal(GLState, Camera)}
 * 
 */
@Override
protected void draw(final GLState pGLState, final Camera pCamera) {
	// Modified by Paul Robinson
	if (this.mTMXTiledMap.getOrientation().equals(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION_VALUE_ORTHOGONAL)) {
		this.drawOrthogonal(pGLState, pCamera);
	} else if (this.mTMXTiledMap.getOrientation()
			.equals(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION_VALUE_ISOMETRIC)) {
		this.drawIsometric(pGLState, pCamera);
	} else {
		Log.w(TAG, String.format("Orientation not supported: '%s'. " + "Will use normal Orthogonal draw method",
				this.mTMXTiledMap.getOrientation()));
		this.drawOrthogonal(pGLState, pCamera);
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:21,代码来源:TMXLayer.java

示例7: drawOrthogonal

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
/**
 * Call if this if the map is Orthogonal <br>
 * This is the original unmodified orthogonal render.
 * 
 * @param pGLState
 * @param pCamera
 */
private void drawOrthogonal(final GLState pGLState, final Camera pCamera) {
	final int tileColumns = this.mTileColumns;
	final int tileRows = this.mTileRows;
	final int tileWidth = this.mTMXTiledMap.getTileWidth();
	final int tileHeight = this.mTMXTiledMap.getTileHeight();

	final float scaledTileWidth = tileWidth * this.mScaleX;
	final float scaledTileHeight = tileHeight * this.mScaleY;

	final float[] cullingVertices = this.mCullingVertices;

	final float layerMinX = cullingVertices[SpriteBatch.VERTEX_INDEX_X];
	final float layerMinY = cullingVertices[SpriteBatch.VERTEX_INDEX_Y];

	final float cameraMinX = pCamera.getXMin();
	final float cameraMinY = pCamera.getYMin();
	final float cameraWidth = pCamera.getWidth();
	final float cameraHeight = pCamera.getHeight();

	/* Determine the area that is visible in the camera. */
	final float firstColumnRaw = (cameraMinX - layerMinX) / scaledTileWidth;
	final int firstColumn = MathUtils.bringToBounds(0, tileColumns - 1, (int) Math.floor(firstColumnRaw));
	final int lastColumn = MathUtils.bringToBounds(0, tileColumns - 1,
			(int) Math.ceil(firstColumnRaw + cameraWidth / scaledTileWidth));

	final float firstRowRaw = (cameraMinY - layerMinY) / scaledTileHeight;
	final int firstRow = MathUtils.bringToBounds(0, tileRows - 1, (int) Math.floor(firstRowRaw));
	final int lastRow = MathUtils.bringToBounds(0, tileRows - 1,
			(int) Math.floor(firstRowRaw + cameraHeight / scaledTileHeight));

	for (int row = firstRow; row <= lastRow; row++) {
		for (int column = firstColumn; column <= lastColumn; column++) {
			this.mSpriteBatchVertexBufferObject.draw(GLES20.GL_TRIANGLE_STRIP,
					this.getSpriteBatchIndex(column, row) * SpriteBatch.VERTICES_PER_SPRITE,
					SpriteBatch.VERTICES_PER_SPRITE);
		}
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:46,代码来源:TMXLayer.java

示例8: drawIsometricCullingLoop

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
/**
 * This loops through all the tiles and checks if the centre location of the
 * tile is within the screen space. <br>
 * It doesn't loop through the TMXTile Arrays, instead it calculates the
 * tile centre using maths. This is not the most efficient way to draw, but
 * FPS is okish. <br>
 * This calculates the tile location
 * 
 * @param pGLState
 * @param pCamera
 */
public void drawIsometricCullingLoop(final GLState pGLState, final Camera pCamera) {
	final float cameraMinX = pCamera.getXMin();
	final float cameraMinY = pCamera.getYMin();
	final float cameraWidth = pCamera.getWidth();
	final float cameraHeight = pCamera.getHeight();
	final int tileColumns = this.mTileColumns;
	final int tileRows = this.mTileRows;

	final int yWholeMax = (int) (cameraMinY + cameraHeight);
	final int yWholeMin = (int) cameraMinY;
	final int xWholeMax = (int) (cameraMinX + cameraWidth);
	final int xWholeMin = (int) cameraMinX;

	for (int j = 0; j < tileRows; j++) {
		for (int i = 0; i < tileColumns; i++) {
			float[] isoCen = this.getIsoTileCentreAt(i, j);
			if (isoCen[1] < yWholeMax && isoCen[1] > yWholeMin) {
				if (isoCen[0] < xWholeMax && isoCen[0] > xWholeMin) {
					this.mSpriteBatchVertexBufferObject.draw(GLES20.GL_TRIANGLE_STRIP,
							this.getSpriteBatchIndex(i, j) * SpriteBatch.VERTICES_PER_SPRITE,
							SpriteBatch.VERTICES_PER_SPRITE);
				}
			}
		}
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:38,代码来源:TMXLayer.java

示例9: drawIsometricCullingLoopExtra

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
/**
 * This loops through all the tiles and checks if the centre location of the
 * tile is within or partly in the screen space. <br>
 * It doesn't loop through the TMXTile Arrays, instead it calculates the
 * tile centre using maths. <br>
 * This is not the most efficient way to draw, but FPS is okish.
 * 
 * @param pGLState
 * @param pCamera
 */
public void drawIsometricCullingLoopExtra(final GLState pGLState, final Camera pCamera) {
	final float cameraMinX = pCamera.getXMin();
	final float cameraMinY = pCamera.getYMin();
	final float cameraWidth = pCamera.getWidth();
	final float cameraHeight = pCamera.getHeight();
	final int tileColumns = this.mTileColumns;
	final int tileRows = this.mTileRows;
	final float tileHeight = this.mTMXTiledMap.getTileHeight();
	final float tileWidth = this.mTMXTiledMap.getTileWidth();

	final int yWholeMax = (int) (cameraMinY + cameraHeight);
	final int yWholeMin = (int) cameraMinY;
	final int yPartialMax = (int) (yWholeMax + tileHeight);
	final int yPartialMin = (int) (yWholeMin - tileHeight);

	final int xWholeMax = (int) (cameraMinX + cameraWidth);
	final int xWholeMin = (int) cameraMinX;
	final int xPartialMax = (int) (xWholeMax + tileWidth);
	final int xPartialMin = (int) (xWholeMin - tileWidth);

	final float[] cullingVertices = this.mCullingVertices;
	for (int j = 0; j < tileRows; j++) {
		for (int i = 0; i < tileColumns; i++) {
			float[] isoCen = this.getIsoTileCentreAt(i, j);
			if (isoCen[1] < yWholeMax && isoCen[1] > yWholeMin || isoCen[1] < yPartialMax
					&& isoCen[1] > yPartialMin) {
				if (isoCen[0] < xWholeMax && isoCen[0] > xWholeMin || isoCen[0] < xPartialMax
						&& isoCen[0] > xPartialMin) {
					this.mSpriteBatchVertexBufferObject.draw(GLES20.GL_TRIANGLE_STRIP,
							this.getSpriteBatchIndex(i, j) * SpriteBatch.VERTICES_PER_SPRITE,
							SpriteBatch.VERTICES_PER_SPRITE);
				}
			}
		}
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:47,代码来源:TMXLayer.java

示例10: 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);
 }
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:43,代码来源:Scrollable.java

示例11: 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));

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:36,代码来源:Scrollable.java

示例12: 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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:ProgressBar.java

示例13: onCreateEngineOptions

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
@Override
public EngineOptions onCreateEngineOptions() {
    Camera camera = new Camera(0,0,WORLD_WIDTH,WORLD_HEIGHT);
    EngineOptions engineOptions = new EngineOptions(true,ScreenOrientation.PORTRAIT_FIXED,new RatioResolutionPolicy(WORLD_WIDTH, WORLD_HEIGHT),camera);
    //engineOptions.getRenderOptions().setDithering(true);
    engineOptions.getAudioOptions().setNeedsMusic(true);
    engineOptions.getAudioOptions().setNeedsSound(true);
    return engineOptions;
}
 
开发者ID:viniciusDSL,项目名称:One-Cachito,代码行数:10,代码来源:GameActivity.java

示例14: onDrawScene

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
protected void onDrawScene(final GLState pGLState, final Camera pCamera) {
	if (this.mScene != null) {
		this.mScene.onDraw(pGLState, pCamera);
	}

	pCamera.onDrawHUD(pGLState);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:8,代码来源:Engine.java

示例15: preDraw

import org.andengine.engine.camera.Camera; //导入依赖的package包/类
@Override
protected void preDraw(final GLState pGLState, final Camera pCamera) {
	super.preDraw(pGLState, pCamera);

	pGLState.lineWidth(this.mLineWidth);

	this.mLineChainVertexBufferObject.bind(pGLState, this.mShaderProgram);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:9,代码来源:LineChain.java


注:本文中的org.andengine.engine.camera.Camera类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。