Java Code Examples for org.andengine.entity.sprite.Sprite#TEXTURECOORDINATES_INDEX_U
The following examples show how to use
org.andengine.entity.sprite.Sprite#TEXTURECOORDINATES_INDEX_U .
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: HighPerformanceTiledSpriteVertexBufferObject.java From tilt-game-android with MIT License | 4 votes |
@Override public void onUpdateTextureCoordinates(final TiledSprite pTiledSprite) { final float[] bufferData = this.mBufferData; final ITiledTextureRegion tiledTextureRegion = pTiledSprite.getTiledTextureRegion(); final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for (int i = 0; i < tileCount; i++) { final ITextureRegion textureRegion = tiledTextureRegion.getTextureRegion(i); final float u; final float v; final float u2; final float v2; if (pTiledSprite.isFlippedVertical()) { // TODO Optimize with field access? if (pTiledSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if (pTiledSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } if (textureRegion.isRotated()) { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } else { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; } bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example 2
Source File: HighPerformanceSpriteVertexBufferObject.java From tilt-game-android with MIT License | 4 votes |
@Override public void onUpdateTextureCoordinates(final Sprite pSprite) { final float[] bufferData = this.mBufferData; final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access? final float u; final float v; final float u2; final float v2; if (pSprite.isFlippedVertical()) { // TODO Optimize with field access? if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } if (textureRegion.isRotated()) { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } else { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; } this.setDirtyOnHardware(); }
Example 3
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java From tilt-game-android with MIT License | 4 votes |
@Override public void onUpdateTextureCoordinates(final Sprite pSprite) { final float[] bufferData = this.mBufferData; final ITextureRegion textureRegion = pSprite.getTextureRegion(); final float u; final float v; final float u2; final float v2; if (pSprite.isFlippedVertical()) { // TODO Optimize with field access? if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } final float uCenter = (u + u2) * 0.5f; final float vCenter = (v + v2) * 0.5f; if (textureRegion.isRotated()) { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; } else { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; } this.setDirtyOnHardware(); }
Example 4
Source File: HighPerformanceTiledSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
@Override public void onUpdateTextureCoordinates(final TiledSprite pTiledSprite) { final float[] bufferData = this.mBufferData; final ITiledTextureRegion tiledTextureRegion = pTiledSprite.getTiledTextureRegion(); final int tileCount = pTiledSprite.getTileCount(); int bufferDataOffset = 0; for(int i = 0; i < tileCount; i++) { final ITextureRegion textureRegion = tiledTextureRegion.getTextureRegion(i); final float u; final float v; final float u2; final float v2; if(pTiledSprite.isFlippedVertical()) { // TODO Optimize with field access? if(pTiledSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if(pTiledSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } if(textureRegion.isRotated()) { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } else { bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE; } this.setDirtyOnHardware(); }
Example 5
Source File: HighPerformanceSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
@Override public void onUpdateTextureCoordinates(final Sprite pSprite) { final float[] bufferData = this.mBufferData; final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access? final float u; final float v; final float u2; final float v2; if(pSprite.isFlippedVertical()) { // TODO Optimize with field access? if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } if(textureRegion.isRotated()) { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } else { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } this.setDirtyOnHardware(); }
Example 6
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
@Override public void onUpdateTextureCoordinates(final Sprite pSprite) { final float[] bufferData = this.mBufferData; final ITextureRegion textureRegion = pSprite.getTextureRegion(); final float u; final float v; final float u2; final float v2; if(pSprite.isFlippedVertical()) { // TODO Optimize with field access? if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV2(); v2 = textureRegion.getV(); } } else { if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access? u = textureRegion.getU2(); u2 = textureRegion.getU(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } else { u = textureRegion.getU(); u2 = textureRegion.getU2(); v = textureRegion.getV(); v2 = textureRegion.getV2(); } } final float uCenter = (u + u2) * 0.5f; final float vCenter = (v + v2) * 0.5f; if(textureRegion.isRotated()) { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; } else { bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u; bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter; bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2; bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter; } this.setDirtyOnHardware(); }