org.andengine.util.debug.Debug Java Examples
The following examples show how to use
org.andengine.util.debug.Debug.
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: PictureBitmapTextureAtlasSource.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public Bitmap onLoadBitmap(final Config pBitmapConfig) { final Picture picture = this.mPicture; if(picture == null) { Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + "."); return null; } final Bitmap bitmap = Bitmap.createBitmap(this.mTextureWidth, this.mTextureHeight, pBitmapConfig); final Canvas canvas = new Canvas(bitmap); final float scaleX = (float)this.mTextureWidth / this.mPicture.getWidth(); final float scaleY = (float)this.mTextureHeight / this.mPicture.getHeight(); canvas.scale(scaleX, scaleY, 0, 0); picture.draw(canvas); return bitmap; }
Example #2
Source File: GenericPool.java From tilt-game-android with MIT License | 6 votes |
public synchronized T obtainPoolItem() { final T item; if (this.mAvailableItems.size() > 0) { item = this.mAvailableItems.remove(this.mAvailableItems.size() - 1); } else { if (this.mGrowth == 1 || this.mAvailableItemCountMaximum == 0) { item = this.onHandleAllocatePoolItem(); } else { this.batchAllocatePoolItems(this.mGrowth); item = this.mAvailableItems.remove(this.mAvailableItems.size() - 1); } if (BuildConfig.DEBUG) { Debug.v(this.getClass().getName() + "<" + item.getClass().getSimpleName() +"> was exhausted, with " + this.mUnrecycledItemCount + " item not yet recycled. Allocated " + this.mGrowth + " more."); } } this.onHandleObtainItem(item); this.mUnrecycledItemCount++; return item; }
Example #3
Source File: ActivityUtils.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public static <T> void doAsync(final Context pContext, final CharSequence pTitle, final CharSequence pMessage, final AsyncCallable<T> pAsyncCallable, final Callback<T> pCallback, final Callback<Exception> pExceptionCallback) { final ProgressDialog pd = ProgressDialog.show(pContext, pTitle, pMessage); pAsyncCallable.call(new Callback<T>() { @Override public void onCallback(final T result) { try { pd.dismiss(); } catch (final Exception e) { Debug.e("Error", e); /* Nothing. */ } pCallback.onCallback(result); } }, pExceptionCallback); }
Example #4
Source File: GenericPool.java From tilt-game-android with MIT License | 6 votes |
public synchronized void recyclePoolItem(final T pItem) { if (pItem == null) { throw new IllegalArgumentException("Cannot recycle null item!"); } this.onHandleRecycleItem(pItem); if (this.mAvailableItems.size() < this.mAvailableItemCountMaximum) { this.mAvailableItems.add(pItem); } this.mUnrecycledItemCount--; if (this.mUnrecycledItemCount < 0) { Debug.e("More items recycled than obtained!"); } }
Example #5
Source File: ShaderProgramManager.java From tilt-game-android with MIT License | 6 votes |
public synchronized void loadShaderProgram(final ShaderProgram pShaderProgram) { if (pShaderProgram == null) { throw new IllegalArgumentException("pShaderProgram must not be null!"); } if (pShaderProgram.isCompiled()) { Debug.w("Loading an already compiled " + ShaderProgram.class.getSimpleName() + ": '" + pShaderProgram.getClass().getSimpleName() + "'. '" + pShaderProgram.getClass().getSimpleName() + "' will be recompiled."); pShaderProgram.setCompiled(false); } if (this.mShaderProgramsManaged.contains(pShaderProgram)) { Debug.w("Loading an already loaded " + ShaderProgram.class.getSimpleName() + ": '" + pShaderProgram.getClass().getSimpleName() + "'."); } else { this.mShaderProgramsManaged.add(pShaderProgram); } }
Example #6
Source File: ETC1Texture.java From tilt-game-android with MIT License | 6 votes |
public ETC1Texture(final TextureManager pTextureManager, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IOException { super(pTextureManager, PixelFormat.RGB_565, pTextureOptions, pTextureStateListener); InputStream inputStream = null; try { inputStream = this.getInputStream(); this.mETC1TextureHeader = new ETC1TextureHeader(StreamUtils.streamToBytes(inputStream, ETC1.ETC_PKM_HEADER_SIZE)); if (BuildConfig.DEBUG) { if (!(MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mWidth) && MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mHeight))) { Debug.w("ETC1 textures with NPOT sizes can cause a crash on PowerVR GPUs!"); } } } finally { StreamUtils.close(inputStream); } }
Example #7
Source File: PictureBitmapTextureAtlasSource.java From tilt-game-android with MIT License | 6 votes |
@Override public Bitmap onLoadBitmap(final Config pBitmapConfig) { final Picture picture = this.mPicture; if (picture == null) { Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + "."); return null; } final Bitmap bitmap = Bitmap.createBitmap(this.mTextureWidth, this.mTextureHeight, pBitmapConfig); final Canvas canvas = new Canvas(bitmap); final float scaleX = (float)this.mTextureWidth / this.mPicture.getWidth(); final float scaleY = (float)this.mTextureHeight / this.mPicture.getHeight(); canvas.scale(scaleX, scaleY, 0, 0); picture.draw(canvas); return bitmap; }
Example #8
Source File: ShaderProgramManager.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public synchronized void loadShaderProgram(final ShaderProgram pShaderProgram) { if(pShaderProgram == null) { throw new IllegalArgumentException("pShaderProgram must not be null!"); } if(pShaderProgram.isCompiled()) { Debug.w("Loading an already compiled " + ShaderProgram.class.getSimpleName() + ": '" + pShaderProgram.getClass().getSimpleName() + "'. '" + pShaderProgram.getClass().getSimpleName() + "' will be recompiled."); pShaderProgram.setCompiled(false); } if(this.mShaderProgramsManaged.contains(pShaderProgram)) { Debug.w("Loading an already loaded " + ShaderProgram.class.getSimpleName() + ": '" + pShaderProgram.getClass().getSimpleName() + "'."); } else { this.mShaderProgramsManaged.add(pShaderProgram); } }
Example #9
Source File: AssetBitmapTextureAtlasSource.java From tilt-game-android with MIT License | 6 votes |
public static AssetBitmapTextureAtlasSource create(final AssetManager pAssetManager, final String pAssetPath, final int pTextureX, final int pTextureY) { final BitmapFactory.Options decodeOptions = new BitmapFactory.Options(); decodeOptions.inJustDecodeBounds = true; InputStream in = null; try { in = pAssetManager.open(pAssetPath); BitmapFactory.decodeStream(in, null, decodeOptions); } catch (final IOException e) { Debug.e("Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: " + pAssetPath, e); } finally { StreamUtils.close(in); } return new AssetBitmapTextureAtlasSource(pAssetManager, pAssetPath, pTextureX, pTextureY, decodeOptions.outWidth, decodeOptions.outHeight); }
Example #10
Source File: FrameCountCrasher.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public void onUpdate(final float pSecondsElapsed) { this.mFramesLeft--; final float[] frameLengths = this.mFrameLengths; if(this.mFramesLeft >= 0) { frameLengths[this.mFramesLeft] = pSecondsElapsed; } else { if(BuildConfig.DEBUG) { for(int i = frameLengths.length - 1; i >= 0; i--) { Debug.d("Elapsed: " + frameLengths[i]); } } throw new RuntimeException(); } }
Example #11
Source File: AssetBitmapTextureAtlasSource.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public Bitmap onLoadBitmap(final Config pBitmapConfig) { InputStream in = null; try { final BitmapFactory.Options decodeOptions = new BitmapFactory.Options(); decodeOptions.inPreferredConfig = pBitmapConfig; in = this.mAssetManager.open(this.mAssetPath); return BitmapFactory.decodeStream(in, null, decodeOptions); } catch (final IOException e) { Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ". AssetPath: " + this.mAssetPath, e); return null; } finally { StreamUtils.close(in); } }
Example #12
Source File: LevelLoader.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public void loadLevelFromStream(final InputStream pInputStream) throws IOException { try{ final SAXParserFactory spf = SAXParserFactory.newInstance(); final SAXParser sp = spf.newSAXParser(); final XMLReader xr = sp.getXMLReader(); this.onBeforeLoadLevel(); final LevelParser levelParser = new LevelParser(this.mDefaultEntityLoader, this.mEntityLoaders); xr.setContentHandler(levelParser); xr.parse(new InputSource(new BufferedInputStream(pInputStream))); this.onAfterLoadLevel(); } catch (final SAXException se) { Debug.e(se); /* Doesn't happen. */ } catch (final ParserConfigurationException pe) { Debug.e(pe); /* Doesn't happen. */ } finally { StreamUtils.close(pInputStream); } }
Example #13
Source File: BaseGameActivity.java From tilt-game-android with MIT License | 6 votes |
@Override protected void onCreate(final Bundle pSavedInstanceState) { if (BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onCreate" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } super.onCreate(pSavedInstanceState); this.mGamePaused = true; this.mEngine = this.onCreateEngine(this.onCreateEngineOptions()); this.mEngine.startUpdateThread(); this.applyEngineOptions(); this.onSetContentView(); }
Example #14
Source File: GenericPool.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public synchronized T obtainPoolItem() { final T item; if(this.mAvailableItems.size() > 0) { item = this.mAvailableItems.remove(this.mAvailableItems.size() - 1); } else { if(this.mGrowth == 1 || this.mAvailableItemCountMaximum == 0) { item = this.onHandleAllocatePoolItem(); } else { this.batchAllocatePoolItems(this.mGrowth); item = this.mAvailableItems.remove(this.mAvailableItems.size() - 1); } if(BuildConfig.DEBUG) { Debug.v(this.getClass().getName() + "<" + item.getClass().getSimpleName() +"> was exhausted, with " + this.mUnrecycledItemCount + " item not yet recycled. Allocated " + this.mGrowth + " more."); } } this.onHandleObtainItem(item); this.mUnrecycledItemCount++; return item; }
Example #15
Source File: Engine.java From tilt-game-android with MIT License | 6 votes |
public void onDestroy() { if (mDestroyed) return; this.mEngineLock.lock(); try { this.mDestroyed = true; this.mEngineLock.notifyCanUpdate(); } finally { this.mEngineLock.unlock(); } try { this.mUpdateThread.join(); } catch (final InterruptedException e) { Debug.e("Could not join UpdateThread.", e); Debug.w("Trying to manually interrupt UpdateThread."); this.mUpdateThread.interrupt(); } this.releaseDefaultDisplay(); this.mVertexBufferObjectManager.onDestroy(); this.mTextureManager.onDestroy(); this.mFontManager.onDestroy(); this.mShaderProgramManager.onDestroy(); }
Example #16
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override protected void onCreate(final Bundle pSavedInstanceState) { if(BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onCreate" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } super.onCreate(pSavedInstanceState); this.mGamePaused = true; this.mEngine = this.onCreateEngine(this.onCreateEngineOptions()); this.mEngine.startUpdateThread(); this.applyEngineOptions(); this.onSetContentView(); }
Example #17
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public synchronized void onSurfaceCreated(final GLState pGLState) { if(BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onSurfaceCreated" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } if(this.mGameCreated) { this.onReloadResources(); if(this.mGamePaused && this.mGameCreated) { this.onResumeGame(); } } else { if(this.mCreateGameCalled) { this.mOnReloadResourcesScheduled = true; } else { this.mCreateGameCalled = true; this.onCreateGame(); } } }
Example #18
Source File: FrameCountCrasher.java From tilt-game-android with MIT License | 6 votes |
@Override public void onUpdate(final float pSecondsElapsed) { this.mFramesLeft--; final float[] frameLengths = this.mFrameLengths; if (this.mFramesLeft >= 0) { frameLengths[this.mFramesLeft] = pSecondsElapsed; } else { if (BuildConfig.DEBUG) { for (int i = frameLengths.length - 1; i >= 0; i--) { Debug.d("Elapsed: " + frameLengths[i]); } } throw new RuntimeException(); } }
Example #19
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
@Override public synchronized void onGameCreated() { this.mGameCreated = true; /* Since the potential asynchronous resource creation, * the surface might already be invalid * and a resource reloading might be necessary. */ if(this.mOnReloadResourcesScheduled) { this.mOnReloadResourcesScheduled = false; try { this.onReloadResources(); } catch(final Throwable pThrowable) { Debug.e(this.getClass().getSimpleName() + ".onReloadResources failed." + " @(Thread: '" + Thread.currentThread().getName() + "')", pThrowable); } } }
Example #20
Source File: SystemUtils.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private static PackageInfo getPackageInfo(final Context pContext) { try { return pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), 0); } catch (final NameNotFoundException e) { Debug.e(e); return null; } }
Example #21
Source File: ButtonSprite.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private void changeState(final State pState) { if(pState == this.mState) { return; } this.mState = pState; final int stateTiledTextureRegionIndex = this.mState.getTiledTextureRegionIndex(); if(stateTiledTextureRegionIndex >= this.mStateCount) { this.setCurrentTileIndex(0); Debug.w(this.getClass().getSimpleName() + " changed its " + State.class.getSimpleName() + " to " + pState.toString() + ", which doesn't have a " + ITextureRegion.class.getSimpleName() + " supplied. Applying default " + ITextureRegion.class.getSimpleName() + "."); } else { this.setCurrentTileIndex(stateTiledTextureRegionIndex); } }
Example #22
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override protected void onPause() { if(BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onPause" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } super.onPause(); this.mRenderSurfaceView.onPause(); this.releaseWakeLock(); if(!this.mGamePaused) { this.onPauseGame(); } }
Example #23
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public synchronized void onGameDestroyed() { if(BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onGameDestroyed" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } this.mGameCreated = false; }
Example #24
Source File: SocketUtils.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
public static final void closeSocket(final ServerSocket pServerSocket) { if(pServerSocket != null && !pServerSocket.isClosed()) { try { pServerSocket.close(); } catch (final IOException e) { Debug.e(e); } } }
Example #25
Source File: SocketUtils.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
public static final void closeSocket(final Socket pSocket) { if(pSocket != null && !pSocket.isClosed()) { try { pSocket.close(); } catch (final IOException e) { Debug.e(e); } } }
Example #26
Source File: StreamUtils.java From tilt-game-android with MIT License | 5 votes |
public static final void flushAndCloseWriter(final Writer pWriter) { if (pWriter != null) { try { pWriter.flush(); } catch (final IOException e) { Debug.e("Error flusing Writer", e); } finally { StreamUtils.close(pWriter); } } }
Example #27
Source File: StreamUtils.java From tilt-game-android with MIT License | 5 votes |
public static final void flushAndCloseStream(final OutputStream pOutputStream) { if (pOutputStream != null) { try { pOutputStream.flush(); } catch (final IOException e) { Debug.e("Error flusing OutputStream", e); } finally { StreamUtils.close(pOutputStream); } } }
Example #28
Source File: StreamUtils.java From tilt-game-android with MIT License | 5 votes |
public static final void close(final Closeable pCloseable) { if (pCloseable != null) { try { pCloseable.close(); } catch (final IOException e) { Debug.e("Error closing Closable", e); } } }
Example #29
Source File: ParallaxBackground.java From tilt-game-android with MIT License | 5 votes |
public ParallaxEntity(final float pParallaxFactor, final IEntity pEntity) { this.mParallaxFactor = pParallaxFactor; this.mEntity = pEntity; // TODO Adjust onDraw calculations, so that these assumptions aren't necessary. if (this.mEntity.getX() != 0) { Debug.w("The X position of a " + this.getClass().getSimpleName() + " is expected to be 0."); } if (this.mEntity.getOffsetCenterX() != 0) { Debug.w("The OffsetCenterXposition of a " + this.getClass().getSimpleName() + " is expected to be 0."); } }
Example #30
Source File: BaseGameActivity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public synchronized void onResumeGame() { if(BuildConfig.DEBUG) { Debug.d(this.getClass().getSimpleName() + ".onResumeGame" + " @(Thread: '" + Thread.currentThread().getName() + "')"); } this.mEngine.start(); this.mGamePaused = false; }