Java Code Examples for org.andengine.entity.sprite.Sprite#getHeight()

The following examples show how to use org.andengine.entity.sprite.Sprite#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HighPerformanceUniformColorSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = 0;
	bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = 0;

	bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = 0;
	bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = height;

	bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = width;
	bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = 0;

	bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = width;
	bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = height;

	this.setDirtyOnHardware();
}
 
Example 2
Source File: HighPerformanceUncoloredSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x;
	bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y;

	bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x;
	bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y2;

	bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x2;
	bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y;

	bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x2;
	bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y2;

	this.setDirtyOnHardware();
}
 
Example 3
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	final float xCenter = (x + x2) * 0.5f;
	final float yCenter = (y + y2) * 0.5f;

	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x;
	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = yCenter;

	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = xCenter;
	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2;

	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = xCenter;
	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y;

	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2;
	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = yCenter;

	this.setDirtyOnHardware();
}
 
Example 4
Source File: LowMemorySpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);

	this.setDirtyOnHardware();
}
 
Example 5
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	final float xCenter = (x + x2) * 0.5f;
	final float yCenter = (y + y2) * 0.5f;

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	this.setDirtyOnHardware();
}
 
Example 6
Source File: HighPerformanceSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x;
	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y;

	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x;
	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2;

	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2;
	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y;

	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2;
	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2;

	this.setDirtyOnHardware();
}
 
Example 7
Source File: LowMemoryDiamondSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	final float xCenter = (x + x2) * 0.5f;
	final float yCenter = (y + y2) * 0.5f;

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	this.setDirtyOnHardware();
}
 
Example 8
Source File: HighPerformanceUniformColorSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = x;
	bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = y;

	bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = x;
	bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = y2;

	bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = x2;
	bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = y;

	bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X] = x2;
	bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y] = y2;

	this.setDirtyOnHardware();
}
 
Example 9
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, x);
	bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, y);

	bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, x);
	bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, y2);

	bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, x2);
	bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, y);

	bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, x2);
	bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, y2);

	this.setDirtyOnHardware();
}
 
Example 10
Source File: HighPerformanceUncoloredSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = 0;
	bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = 0;

	bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = 0;
	bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = height;

	bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = width;
	bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = 0;

	bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = width;
	bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = height;

	this.setDirtyOnHardware();
}
 
Example 11
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	final float halfWidth = width * 0.5f;
	final float halfHeight = height * 0.5f;

	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = halfWidth;
	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = 0;

	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = 0;
	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = halfHeight;

	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = width;
	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = halfHeight;

	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = halfWidth;
	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = height;

	this.setDirtyOnHardware();
}
 
Example 12
Source File: LowMemorySpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, 0);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, 0);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, 0);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, height);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, width);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, 0);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, width);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, height);

	this.setDirtyOnHardware();
}
 
Example 13
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, 0);
	bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, 0);

	bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, 0);
	bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, height);

	bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, width);
	bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, 0);

	bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, width);
	bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, height);

	this.setDirtyOnHardware();
}
 
Example 14
Source File: HighPerformanceSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = 0;
	bufferData[0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = 0;

	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = 0;
	bufferData[1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = height;

	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = width;
	bufferData[2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = 0;

	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = width;
	bufferData[3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = height;

	this.setDirtyOnHardware();
}
 
Example 15
Source File: LowMemoryDiamondSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	final float halfWidth = width * 0.5f;
	final float halfHeight = height * 0.5f;

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, halfWidth);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, 0);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, 0);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, halfHeight);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, width);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, halfHeight);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, halfWidth);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, height);

	this.setDirtyOnHardware();
}
 
Example 16
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float width = pSprite.getWidth(); // TODO Optimize with field access?
	final float height = pSprite.getHeight(); // TODO Optimize with field access?

	bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, 0);
	bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, 0);

	bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, 0);
	bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, height);

	bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, width);
	bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, 0);

	bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, width);
	bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, height);

	this.setDirtyOnHardware();
}
 
Example 17
Source File: BaseOnScreenControl.java    From tilt-game-android with MIT License 5 votes vote down vote up
/**
 * @param pRelativeX from <code>-0.5f</code> (left) to <code>0.5</code> (right).
 * @param pRelativeY from <code>-0.5f</code> (bottom) to <code>0.5f</code> (top).
 */
protected void onUpdateControlKnob(final float pRelativeX, final float pRelativeY) {
	final Sprite controlBase = this.mControlBase;
	final Sprite controlKnob = this.mControlKnob;

	this.mControlValueX = 2 * pRelativeX;
	this.mControlValueY = 2 * pRelativeY;

	final float x = controlBase.getWidth() * (0.5f + pRelativeX);
	final float y = controlBase.getHeight() * (0.5f + pRelativeY);

	controlKnob.setPosition(x, y);
}
 
Example 18
Source File: BaseOnScreenControl.java    From tilt-game-android with MIT License 5 votes vote down vote up
private void updateControlKnob(final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
	final Sprite controlBase = this.mControlBase;

	final float relativeX = (MathUtils.bringToBounds(0, controlBase.getWidth(), pTouchAreaLocalX) / controlBase.getWidth()) - 0.5f;
	final float relativeY = (MathUtils.bringToBounds(0, controlBase.getHeight(), pTouchAreaLocalY) / controlBase.getHeight()) - 0.5f;

	this.onUpdateControlKnob(relativeX, relativeY);
}
 
Example 19
Source File: BaseOnScreenControl.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
private void updateControlKnob(final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
	final Sprite controlBase = this.mControlBase;

	final float relativeX = MathUtils.bringToBounds(0, controlBase.getWidth(), pTouchAreaLocalX) / controlBase.getWidth() - 0.5f;
	final float relativeY = MathUtils.bringToBounds(0, controlBase.getHeight(), pTouchAreaLocalY) / controlBase.getHeight() - 0.5f;

	this.onUpdateControlKnob(relativeX, relativeY);
}
 
Example 20
Source File: BaseOnScreenControl.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
/**
 * @param pRelativeX from <code>-0.5</code> (left) to <code>0.5</code> (right).
 * @param pRelativeY from <code>-0.5</code> (top) to <code>0.5</code> (bottom).
 */
protected void onUpdateControlKnob(final float pRelativeX, final float pRelativeY) {
	final Sprite controlBase = this.mControlBase;
	final Sprite controlKnob = this.mControlKnob;

	this.mControlValueX = 2 * pRelativeX;
	this.mControlValueY = 2 * pRelativeY;

	final float[] controlBaseSceneCenterCoordinates = controlBase.getSceneCenterCoordinates();
	final float x = controlBaseSceneCenterCoordinates[VERTEX_INDEX_X] - controlKnob.getWidth() * 0.5f + pRelativeX * controlBase.getWidthScaled();
	final float y = controlBaseSceneCenterCoordinates[VERTEX_INDEX_Y] - controlKnob.getHeight() * 0.5f + pRelativeY * controlBase.getHeightScaled();

	controlKnob.setPosition(x, y);
}