org.andengine.entity.sprite.Sprite Java Examples
The following examples show how to use
org.andengine.entity.sprite.Sprite.
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: HighPerformanceDiamondSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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 #2
Source File: HighPerformanceSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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 #3
Source File: RepeatingSpriteBackground.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
private Sprite loadSprite(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final VertexBufferObjectManager pVertexBufferObjectManager) throws IllegalArgumentException { this.mBitmapTextureAtlas = new BitmapTextureAtlas(pTextureManager, pBitmapTextureAtlasSource.getTextureWidth(), pBitmapTextureAtlasSource.getTextureHeight(), BitmapTextureFormat.RGBA_8888, TextureOptions.REPEATING_NEAREST); final ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mBitmapTextureAtlas, pBitmapTextureAtlasSource, 0, 0); final int width = Math.round(pCameraWidth / this.mScale); final int height = Math.round(pCameraHeight / this.mScale); textureRegion.setTextureWidth(width); textureRegion.setTextureHeight(height); this.mBitmapTextureAtlas.load(); final Sprite sprite = new Sprite(0, 0, width, height, textureRegion, pVertexBufferObjectManager); sprite.setScaleCenter(0, 0); sprite.setScale(this.mScale); return sprite; }
Example #4
Source File: BatchedSpriteParticleSystem.java From tilt-game-android with MIT License | 6 votes |
@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); }
Example #5
Source File: LowMemoryDiamondSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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: HighPerformanceTiledSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@Override public void onUpdateColor(final TiledSprite pTiledSprite) { final float[] bufferData = this.mBufferData; final float packedColor = pTiledSprite.getColor().getABGRPackedFloat(); final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for (int i = 0; i < tileCount; i++) { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor; bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example #7
Source File: BatchedSpriteParticleSystem.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: HighPerformanceUniformColorSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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: LowMemoryTiledSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@Override public void onUpdateColor(final TiledSprite pTiledSprite) { final FloatBuffer bufferData = this.mFloatBuffer; final float packedColor = pTiledSprite.getColor().getABGRPackedFloat(); final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for (int i = 0; i < tileCount; i++) { bufferData.put(bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example #10
Source File: HighPerformanceUncoloredSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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 #11
Source File: LevelModeCompleteScene.java From sopa with Apache License 2.0 | 6 votes |
LevelModeCompleteScene() { Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.05), resourcesManager.levelModeCompleteFont, "Level Mode\nCompleted", vbom); levelCompleteTextShape.setScaleCenter(0, 0); attachChild(levelCompleteTextShape); Sprite cup = new Sprite(0, 0, resourcesManager.levelModeCup, vbom); cup.setPosition(camera.getWidth() / 2 - cup.getWidth() / 2, camera.getHeight() * 0.4f); attachChild(cup); attachChild(new ConfettiParticleSystem(vbom, camera.getWidth())); setOnSceneTouchListener(new IOnSceneTouchListener() { @Override public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) { onBackKeyPressed(); return false; } }); }
Example #12
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #13
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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 #14
Source File: LoadingScene.java From sopa with Apache License 2.0 | 6 votes |
LoadingScene() { super(); float spriteSTartY = (camera.getHeight() - camera.getWidth()) / 2; setBackground(new Background(Color.BLACK)); this.attachChild(new Sprite(0, spriteSTartY, camera.getWidth(), camera.getWidth(), ResourcesManager.getInstance().loadingScreenBackgroundRegion, vbom) { @Override protected void preDraw(GLState pGLState, Camera pCamera) { super.preDraw(pGLState, pCamera); pGLState.enableDither(); } }); }
Example #15
Source File: LowMemorySpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@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 #16
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #17
Source File: LowMemoryDiamondSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #18
Source File: LowMemorySpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #19
Source File: HighPerformanceSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #20
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
@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 #21
Source File: LowMemoryTiledSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public void onUpdateColor(final TiledSprite pTiledSprite) { final FloatBuffer bufferData = this.mFloatBuffer; final float packedColor = pTiledSprite.getColor().getABGRPackedFloat(); final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for(int i = 0; i < tileCount; i++) { bufferData.put(bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example #22
Source File: TutorialScene.java From sopa with Apache License 2.0 | 6 votes |
TutorialScene() { firstScreenA = new Sprite(0, 0, 1080, 960, resourcesManager.tutorialFirstRegionA, vbom); firstScreenB = new Sprite(0, 960, 1080, 960, resourcesManager.tutorialFirstRegionB, vbom); letsGo = new Sprite(146, 843, resourcesManager.tutorialLetsGoRegion, vbom); letsGo.setVisible(false); secondScreenA = new Sprite(0, 0, 1080, 960, resourcesManager.tutorialSecondRegionA, vbom); secondScreenB = new Sprite(0, 960, 1080, 960, resourcesManager.tutorialSecondRegionB, vbom); secondScreenA.setVisible(false); secondScreenB.setVisible(false); setOnSceneTouchListener(this); attachChild(firstScreenA); attachChild(firstScreenB); attachChild(secondScreenA); attachChild(secondScreenB); attachChild(letsGo); }
Example #23
Source File: LowMemorySpriteVertexBufferObject.java From tilt-game-android with MIT License | 5 votes |
@Override public void onUpdateColor(final Sprite pSprite) { final FloatBuffer bufferData = this.mFloatBuffer; final float packedColor = pSprite.getColor().getABGRPackedFloat(); bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); this.setDirtyOnHardware(); }
Example #24
Source File: BaseOnScreenControl.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
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 #25
Source File: BaseOnScreenControl.java From tilt-game-android with MIT License | 5 votes |
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 #26
Source File: WorldController.java From tilt-game-android with MIT License | 5 votes |
private void createBackground(final Bitmap background, @Nullable final String backgroundUrl) { if (background == null) return; BitmapTextureAtlas bitmapTextureAtlas = new BitmapTextureAtlas(_engine.getTextureManager(), _width, _height, TextureOptions.BILINEAR); IBitmapTextureAtlasSource baseTextureSource = new EmptyBitmapTextureAtlasSource(_width, _height); final IBitmapTextureAtlasSource bitmapTextureAtlasSource = new BaseBitmapTextureAtlasSourceDecorator(baseTextureSource) { @Override protected void onDecorateBitmap(Canvas pCanvas) throws Exception { if (backgroundUrl != null) { Bitmap template = BitmapFactory.decodeStream(GoogleFlipGameApplication.sContext.getAssets().open(backgroundUrl)); pCanvas.drawBitmap(template, 0, 0, mPaint); } pCanvas.drawColor(_backgroundColor); pCanvas.drawBitmap(background, 0, 0, mPaint); } @Override public BaseBitmapTextureAtlasSourceDecorator deepCopy() { throw new IModifier.DeepCopyNotSupportedException(); } }; ITextureRegion mDecoratedBalloonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(bitmapTextureAtlas, bitmapTextureAtlasSource, 0, 0); bitmapTextureAtlas.load(); Sprite sprite = new Sprite(0, 0, mDecoratedBalloonTextureRegion, _engine.getVertexBufferObjectManager()); sprite.setOffsetCenter(0, 0); sprite.setWidth(_width); sprite.setHeight(_height); _background = new SpriteBackground(sprite); _engine.getScene().setBackground(_background); }
Example #27
Source File: SpriteGroup.java From tilt-game-android with MIT License | 5 votes |
/** * Instead use {@link #attachChild(BaseSprite)}. */ @Override @Deprecated public void attachChild(final IEntity pEntity) throws IllegalArgumentException { if (pEntity instanceof Sprite) { this.attachChild((Sprite) pEntity); } else { throw new IllegalArgumentException("A " + SpriteGroup.class.getSimpleName() + " can only handle children of type Sprite or subclasses of Sprite, like TiledSprite or AnimatedSprite."); } }
Example #28
Source File: HighPerformanceTiledSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public void onUpdateVertices(final TiledSprite pTiledSprite) { final float[] bufferData = this.mBufferData; final float x = 0; final float y = 0; final float x2 = pTiledSprite.getWidth(); // TODO Optimize with field access? final float y2 = pTiledSprite.getHeight(); // TODO Optimize with field access? final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for(int i = 0; i < tileCount; i++) { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x; bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X] = x2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y] = y2; bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example #29
Source File: BaseOnScreenControl.java From tilt-game-android with MIT License | 5 votes |
public BaseOnScreenControl(final float pX, final float pY, final Camera pCamera, final ITextureRegion pControlBaseTextureRegion, final ITextureRegion pControlKnobTextureRegion, final float pTimeBetweenUpdates, final VertexBufferObjectManager pVertexBufferObjectManager, final IOnScreenControlListener pOnScreenControlListener) { this.setCamera(pCamera); this.mOnScreenControlListener = pOnScreenControlListener; /* Create the control base. */ this.mControlBase = new Sprite(pX, pY, pControlBaseTextureRegion, pVertexBufferObjectManager) { @Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { return BaseOnScreenControl.this.onHandleControlBaseTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY); } }; /* Create the control knob. */ this.mControlKnob = new Sprite(0, 0, pControlKnobTextureRegion, pVertexBufferObjectManager); this.onHandleControlKnobReleased(); /* Register listeners and add objects to this HUD. */ this.setOnSceneTouchListener(this); this.registerTouchArea(this.mControlBase); this.registerUpdateHandler(new TimerHandler(pTimeBetweenUpdates, true, new ITimerCallback() { @Override public void onTimePassed(final TimerHandler pTimerHandler) { BaseOnScreenControl.this.mOnScreenControlListener.onControlChange(BaseOnScreenControl.this, BaseOnScreenControl.this.mControlValueX, BaseOnScreenControl.this.mControlValueY); } })); this.attachChild(this.mControlBase); this.mControlBase.attachChild(this.mControlKnob); this.setTouchAreaBindingOnActionDownEnabled(true); }
Example #30
Source File: LowMemorySpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public void onUpdateColor(final Sprite pSprite) { final FloatBuffer bufferData = this.mFloatBuffer; final float packedColor = pSprite.getColor().getABGRPackedFloat(); bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor); this.setDirtyOnHardware(); }