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


Java Camera.getWidth方法代码示例

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


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

示例1: onDraw

import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
public void onDraw(final GLState pGLState, final Camera pCamera, final float pParallaxValue) {
	pGLState.pushModelViewGLMatrix();
	{
		final float cameraWidth = pCamera.getWidth();
		final float entityWidthScaled = this.mEntity.getWidth() * this.mEntity.getScaleX();
		float baseOffset = (pParallaxValue * this.mParallaxFactor) % entityWidthScaled;

		while (baseOffset > 0) {
			baseOffset -= entityWidthScaled;
		}
		pGLState.translateModelViewGLMatrixf(baseOffset, 0, 0);

		float currentMaxX = baseOffset;

		do {
			this.mEntity.onDraw(pGLState, pCamera);
			pGLState.translateModelViewGLMatrixf(entityWidthScaled, 0, 0);
			currentMaxX += entityWidthScaled;
		} while (currentMaxX < cameraWidth);
	}
	pGLState.popModelViewGLMatrix();
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:23,代码来源:ParallaxBackground.java

示例2: onDraw

import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
public void onDraw(final GLState pGLState, final Camera pCamera, final float pParallaxValue) {
	pGLState.pushModelViewGLMatrix();
	{
		final float cameraWidth = pCamera.getWidth();
		final float shapeWidthScaled = this.mAreaShape.getWidthScaled();
		float baseOffset = (pParallaxValue * this.mParallaxFactor) % shapeWidthScaled;

		while(baseOffset > 0) {
			baseOffset -= shapeWidthScaled;
		}
		pGLState.translateModelViewGLMatrixf(baseOffset, 0, 0);

		float currentMaxX = baseOffset;
		
		do {
			this.mAreaShape.onDraw(pGLState, pCamera);
			pGLState.translateModelViewGLMatrixf(shapeWidthScaled, 0, 0);
			currentMaxX += shapeWidthScaled;
		} while(currentMaxX < cameraWidth);
	}
	pGLState.popModelViewGLMatrix();
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:23,代码来源:ParallaxBackground.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: createCameraWalls

import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
protected void createCameraWalls(boolean up, boolean right, boolean down, boolean left, boolean masked) {
    final Camera camera = activity.getCamera();
    final float camWidth = camera.getWidth();
    final float camHeight = camera.getHeight();
    final float wallDepth = 10;

    final float centerX = camWidth / 2;
    final float centerY = camHeight / 2;

    if (down) createWall(centerX, camHeight + wallDepth / 2, camWidth, wallDepth, Wall.Type.BOTTOM, masked);
    if (up) createWall(centerX, -wallDepth / 2, camWidth, wallDepth, Wall.Type.TOP, masked);
    if (left) createWall(-wallDepth / 2, centerY, wallDepth, camHeight, Wall.Type.LEFT, masked);
    if (right) createWall(camWidth + wallDepth / 2, centerY, wallDepth, camHeight, Wall.Type.RIGHT, masked);
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:15,代码来源:BaseGame.java

示例9: drawIsometricCullingTiledSource

import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
/**
 * Culling method taken from method paintLayer in IsoMapView.java from Tiled
 * 0.7.2 source code. <br>
 * Not to dissimilar to the function drawTileLayer in isometricrenderer.cpp
 * from Tiled 0.8.0 source code. <br>
 * Slight performance gain and draws tiles in a different order than the
 * others, this does not appear to cause any problems. The tiles original Z
 * order are unaffected. <br>
 * Copyright 2009-2011, Thorbjorn Lindeijer <[email protected]>
 * 
 * @param pGLState
 * @param pCamera
 */
public void drawIsometricCullingTiledSource(final GLState pGLState, final Camera pCamera) {
	/*
	 * Copyright 2009-2011, Thorbjorn Lindeijer <[email protected]>
	 * <br><a href="http://sourceforge.net/projects/tiled/files/Tiled/0.7.2/tiled-0.7.2-src.zip/">Tiled 0.7.2 source code zip</a>
	 * <br><a href="https://github.com/bjorn/tiled/blob/master/src/libtiled/isometricrenderer.cpp">Tiled 0.8.0 source code - isometricrenderer.cpp on Github</a>
	 * Copied across and changed slightly by Paul Robinson.
	 * Changes being using an int array rather than Point object, 
	 * The original Tiled Java source code used Point objects.
	 */
	final int tileWidth = this.mTMXTiledMap.getTileWidth();
	final int tileHeight = this.mTMXTiledMap.getTileHeight();
	/*
	 *  Since using AnchorCenter camera Y min is bottom left, so add the camera height
	 */
	final float cameraMinX = pCamera.getXMin();
	final float cameraMinY = pCamera.getYMin() + pCamera.getHeight();
	final float cameraWidth = pCamera.getWidth();
	final float cameraHeight = pCamera.getHeight();
	
	final float pY = cameraMinY < 0 ? Math.abs(cameraMinY) : 0 - cameraMinY;
	int[] rowItr = this.screenToTileCoords(cameraMinX, pY);
	rowItr[0]--;
	
	/*
	 *  Determine area to draw from clipping rectangle
	 *  Row calculation has changed
	 */
	int columns = (int) (cameraWidth / tileWidth + 3);
	int rows = (int) (cameraHeight / (tileHeight/2) + 4);
	// Draw this map layer
	for (int y = 0; y < rows; y++) {
		int[] columnItr = { rowItr[0], rowItr[1] };
		for (int x = 0; x < columns; x++) {
			if (columnItr[0] >= 0 && columnItr[0] < this.mTileColumns) {
				if (columnItr[1] >= 0 && columnItr[1] < this.mTileRows) {
					this.mSpriteBatchVertexBufferObject.draw(GLES20.GL_TRIANGLE_STRIP,
							this.getSpriteBatchIndex(columnItr[0], columnItr[1]) * SpriteBatch.VERTICES_PER_SPRITE,
							SpriteBatch.VERTICES_PER_SPRITE);
				}
			}
			// Advance to the next tile
			columnItr[0]++;
			columnItr[1]--;
		}
		if ((y & 1) > 0) {
			rowItr[0]++;
		} else {
			rowItr[1]++;
		}
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:65,代码来源:TMXLayer.java

示例10: initViews

import org.andengine.engine.camera.Camera; //导入方法依赖的package包/类
public void initViews(final ResourceManager pResourceManager, final Camera pCamera) {

		final float cameraHeight = pCamera.getHeight();
		final float cameraWidth = pCamera.getWidth();

		mRacer = new Racer(GameActivity.NUM_OF_LIVES, cameraWidth, cameraHeight, pResourceManager.mRaceCarRegion, mContext.getVertexBufferObjectManager());
		mRacer.setY(cameraHeight - mRacer.getHeight() - 15f);

		final int textOffsetX = (int) (cameraWidth * RACE_TRACK_WIDTH) + 20;
		// scores
		mHighScore = new Text(textOffsetX, 100, pResourceManager.mGameFont, "High Score\n 0123456789", new TextOptions(HorizontalAlign.LEFT), mContext.getVertexBufferObjectManager());
		mHighScore.setText("High Score \n " + Persistance.getHighScore(mContext));
		mScore = new Text(textOffsetX, 180, pResourceManager.mGameFont, "Score \n0123456789", mContext.getVertexBufferObjectManager());
		mLives = new Text(textOffsetX, 260, pResourceManager.mGameFont, "Lives \n01234556789", mContext.getVertexBufferObjectManager());
		mLives.setText("Lives \n " + mRacer.mLivesLeft);
		mLevel = new Text(textOffsetX, 340, pResourceManager.mGameFont, "Level\n 0123456789", mContext.getVertexBufferObjectManager());

		mScore.setText("Score \n 0");

		// menus
		mPlayText = new Text(cameraWidth / 2, cameraHeight / 3, pResourceManager.mGamePlayFont, "Play", 5, new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mLevelText = new Text(cameraWidth / 2, cameraHeight / 3 + mPlayText.getHeight() + 40f, pResourceManager.mGamePlayFont, "Level", 5, new TextOptions(HorizontalAlign.CENTER),
				mContext.getVertexBufferObjectManager());
		mHelpText = new Text(cameraWidth / 2, cameraHeight / 3 + mLevelText.getHeight() + mPlayText.getHeight() + 80f, pResourceManager.mGamePlayFont, "Help", 4, new TextOptions(
				HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());

		// game over
		mExplosionSprite = new Sprite(-500f, mRacer.getY(), pResourceManager.mExplosionRegion, mContext.getVertexBufferObjectManager());
		mGameOverText = new Text(cameraWidth / 2, cameraHeight / 3, pResourceManager.mGamePlayFont, "Score", 5, new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mGameOverScoreText = new Text(cameraWidth / 2, cameraHeight / 3 + mGameOverText.getHeight() + 40, pResourceManager.mGamePlayFont, " 0123456789", 12, new TextOptions(HorizontalAlign.CENTER),
				mContext.getVertexBufferObjectManager());
		mExplosionSprite.setCullingEnabled(true);
		mExplosionSprite.setZIndex(3);

		mPlayText.setAlpha(0.7f);
		mHelpText.setAlpha(0.7f);
		mLevelText.setAlpha(0.7f);
		mGameOverText.setAlpha(0.7f);
		mGameOverScoreText.setAlpha(0.7f);
		mGameOverText.setColor(mGameOverTextColor);
		mGameOverScoreText.setColor(mGameOverTextColor);

		mPlayText.setZIndex(6);
		mLevelText.setZIndex(6);
		mHelpText.setZIndex(6);
		mGameOverText.setZIndex(7);
		mGameOverScoreText.setZIndex(7);

		placeCenter(mPlayText, pCamera);
		placeCenter(mHelpText, pCamera);
		placeCenter(mLevelText, pCamera);
		placeCenter(mGameOverText, pCamera);
		placeCenter(mGameOverScoreText, pCamera);

		registerTouchArea(mHelpText);
		registerTouchArea(mPlayText);
		registerTouchArea(mLevelText);
		attachChild(mHelpText);
		attachChild(mPlayText);
		attachChild(mLevelText);
		attachChild(mHighScore);
		attachChild(mScore);
		attachChild(mLives);
		attachChild(mLevel);
		attachChild(mRacer);
		attachChild(mExplosionSprite);
		sortChildren();

	}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:70,代码来源:GameScene.java


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