org.andengine.entity.primitive.Rectangle Java Examples

The following examples show how to use org.andengine.entity.primitive.Rectangle. 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: HighPerformanceRectangleVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
	final float[] bufferData = this.mBufferData;

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

	bufferData[(0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = 0;
	bufferData[(0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = 0;

	bufferData[(1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = 0;
	bufferData[(1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = height;

	bufferData[(2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = width;
	bufferData[(2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = 0;

	bufferData[(3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = width;
	bufferData[(3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = height;

	this.setDirtyOnHardware();
}
 
Example #2
Source File: JustPlayLostScene.java    From sopa with Apache License 2.0 6 votes vote down vote up
private void addRectangles() {

        Rectangle rectangleScore = new Rectangle(0, (float) (camera.getHeight() * 0.45), camera.getWidth(),
                textFieldHeight, vbom);
        rectangleScore.setColor(0, 102 / 255f, 255 / 255f);
        attachChild(rectangleScore);

        Rectangle rectangleLevel = new Rectangle(0, rectangleScore.getY() + textFieldHeight, camera.getWidth(),
                rectangleScore.getHeight(), vbom);
        rectangleLevel.setColor(YELLOW);
        attachChild(rectangleLevel);

        if (justPlayScoreService.getHighscore() != null) {
            Rectangle rectangleHighscore = new Rectangle(0, rectangleLevel.getY() + textFieldHeight, camera.getWidth(),
                    textFieldHeight, vbom);
            rectangleHighscore.setColor(153 / 255f, 102 / 255f, 0);
            attachChild(rectangleHighscore);
        }
    }
 
Example #3
Source File: LowMemoryRectangleVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
	final FloatBuffer bufferData = this.mFloatBuffer;

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

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

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

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

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

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

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

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

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

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

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

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

	final float x = 0;
	final float y = 0;
	final float x2 = pRectangle.getWidth();
	final float y2 = pRectangle.getHeight();

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

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

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

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

	this.setDirtyOnHardware();
}
 
Example #6
Source File: ConfettiParticleSystem.java    From sopa with Apache License 2.0 5 votes vote down vote up
private static IEntityFactory<Rectangle> createEntityFactory(final VertexBufferObjectManager vbom) {

        return new IEntityFactory<Rectangle>() {
            @Override
            public Rectangle create(final float pX, final float pY) {

                Rectangle rectangle = new Rectangle(pX, pY, 30, 15, vbom);
                rectangle.setColor(COLOR_MAP[getRandomBetweenZeroAndThree()]);
                rectangle.registerEntityModifier(new RotationModifier(7f, (float) Math.random() * 360,
                        (7 - (float) Math.random() * 15) * 360));
                rectangle.registerEntityModifier(new AlphaModifier(4f, 0.7f, 0f));
                return rectangle;
            }};
    }
 
Example #7
Source File: HighPerformanceRectangleVertexBufferObject.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public void onUpdateColor(final Rectangle pRectangle) {
	final float[] bufferData = this.mBufferData;

	final float packedColor = pRectangle.getColor().getABGRPackedFloat();

	bufferData[(0 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[(1 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[(2 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[(3 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX] = packedColor;

	this.setDirtyOnHardware();
}
 
Example #8
Source File: JustPlayScoreScene.java    From sopa with Apache License 2.0 5 votes vote down vote up
private void addRectangles() {

        Rectangle rectangleScore = new Rectangle(0, (float) (camera.getHeight() * 0.45), camera.getWidth(),
                camera.getHeight() * 0.085f, vbom);
        rectangleScore.setColor(0, 102 / 255f, 255 / 255f);
        attachChild(rectangleScore);

        Rectangle rectangleTime = new Rectangle(0, (float) (camera.getHeight() * 0.6), camera.getWidth(),
                camera.getHeight() * 0.17f, vbom);
        rectangleTime.setColor(153 / 255f, 0, 0);
        attachChild(rectangleTime);
    }
 
Example #9
Source File: JustPlayGameScene.java    From sopa with Apache License 2.0 5 votes vote down vote up
private void initializeWarningFlash() {

        gameViewBackground = new Rectangle(0f, getTileSceneStartY() + spacePerTile, camera.getWidth(),
                camera.getWidth(), vbom);
        gameViewBackground.setColor(1f, 1f, 1f, 0f);
        attachChild(gameViewBackground);
    }
 
Example #10
Source File: LowMemoryRectangleVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdateColor(final Rectangle pRectangle) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float packedColor = pRectangle.getColor().getABGRPackedFloat();

	bufferData.put(0 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put(1 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put(2 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put(3 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX, packedColor);

	this.setDirtyOnHardware();
}
 
Example #11
Source File: HighPerformanceRectangleVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdateColor(final Rectangle pRectangle) {
	final float[] bufferData = this.mBufferData;

	final float packedColor = pRectangle.getColor().getABGRPackedFloat();

	bufferData[0 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[1 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[2 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX] = packedColor;
	bufferData[3 * Rectangle.VERTEX_SIZE + Rectangle.COLOR_INDEX] = packedColor;

	this.setDirtyOnHardware();
}
 
Example #12
Source File: LowMemoryRectangleVertexBufferObject.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public void onUpdateColor(final Rectangle pRectangle) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float packedColor = pRectangle.getColor().getABGRPackedFloat();

	bufferData.put((0 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put((1 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put((2 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX, packedColor);
	bufferData.put((3 * Rectangle.VERTEX_SIZE) + Rectangle.COLOR_INDEX, packedColor);

	this.setDirtyOnHardware();
}
 
Example #13
Source File: ConfettiParticleSystem.java    From sopa with Apache License 2.0 4 votes vote down vote up
public ConfettiParticleSystem(final VertexBufferObjectManager vbom, float cameraWidth) {

        super(createEntityFactory(vbom), new HorizontalLineParticleEmitter(0, 0, cameraWidth), 50f, 100f, 200);
        addParticleInitializer(new VelocityParticleInitializer<Rectangle>(-20, 20, 250, 300));
        addParticleInitializer(new GravityParticleInitializer<Rectangle>());
    }
 
Example #14
Source File: IRectangleVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public void onUpdateVertices(final Rectangle pRectangle); 
Example #15
Source File: IRectangleVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public void onUpdateColor(final Rectangle pRectangle); 
Example #16
Source File: IRectangleVertexBufferObject.java    From tilt-game-android with MIT License votes vote down vote up
public void onUpdateVertices(final Rectangle pRectangle); 
Example #17
Source File: IRectangleVertexBufferObject.java    From tilt-game-android with MIT License votes vote down vote up
public void onUpdateColor(final Rectangle pRectangle);