Java Code Examples for org.andengine.util.debug.Debug#e()

The following examples show how to use org.andengine.util.debug.Debug#e() . 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: BaseGameActivity.java    From tilt-game-android with MIT License 6 votes vote down vote up
@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 2
Source File: BaseGameActivity.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
protected void onDestroy() {
	if (BuildConfig.DEBUG) {
		Debug.d(this.getClass().getSimpleName() + ".onDestroy" + " @(Thread: '" + Thread.currentThread().getName() + "')");
	}

	super.onDestroy();

	this.mEngine.onDestroy();

	try {
		this.onDestroyResources();
	} catch (final Throwable pThrowable) {
		Debug.e(this.getClass().getSimpleName() + ".onDestroyResources failed." + " @(Thread: '" + Thread.currentThread().getName() + "')", pThrowable);
	}

	this.onGameDestroyed();

	this.mEngine = null;
}
 
Example 3
Source File: LevelLoader.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
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 4
Source File: PictureBitmapTextureAtlasSource.java    From tilt-game-android with MIT License 6 votes vote down vote up
@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 5
Source File: AssetBitmapTextureAtlasSource.java    From tilt-game-android with MIT License 6 votes vote down vote up
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 6
Source File: PictureBitmapTextureAtlasSource.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: AssetBitmapTextureAtlasSource.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@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 8
Source File: BaseBitmapTextureAtlasSourceDecorator.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
	final Bitmap bitmap = BaseBitmapTextureAtlasSourceDecorator.ensureLoadedBitmapIsMutable(this.mBitmapTextureAtlasSource.onLoadBitmap(pBitmapConfig));

	final Canvas canvas = new Canvas(bitmap);
	try {
		this.onDecorateBitmap(canvas);
	} catch (final Exception e) {
		Debug.e(e);
	}
	return bitmap;
}
 
Example 9
Source File: SystemUtils.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
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 10
Source File: SocketUtils.java    From tilt-game-android with MIT License 5 votes vote down vote up
public static final void closeSocket(final ServerSocket pServerSocket) {
	if (pServerSocket != null && !pServerSocket.isClosed()) {
		try {
			pServerSocket.close();
		} catch (final IOException e) {
			Debug.e(e);
		}
	}
}
 
Example 11
Source File: BaseGameActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) {
	if(pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
		ActivityUtils.keepScreenOn(this);
	} else {
		final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
		this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, Constants.DEBUGTAG);
		try {
			this.mWakeLock.acquire();
		} catch (final SecurityException pSecurityException) {
			Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", pSecurityException);
		}
	}
}
 
Example 12
Source File: StreamUtils.java    From tilt-game-android with MIT License 5 votes vote down vote up
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 13
Source File: StreamUtils.java    From tilt-game-android with MIT License 5 votes vote down vote up
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 14
Source File: SocketUtils.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
public static final void closeSocket(final ServerSocket pServerSocket) {
	if(pServerSocket != null && !pServerSocket.isClosed()) {
		try {
			pServerSocket.close();
		} catch (final IOException e) {
			Debug.e(e);
		}
	}
}
 
Example 15
Source File: Engine.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public boolean onTouch(final View pView, final MotionEvent pSurfaceMotionEvent) {
	if (this.mRunning) {
		this.mTouchController.onHandleMotionEvent(pSurfaceMotionEvent);
		try {
			/* Because a human cannot interact 1000x per second, we pause the UI-Thread for a little. */
			Thread.sleep(this.mEngineOptions.getTouchOptions().getTouchEventIntervalMilliseconds());
		} catch (final InterruptedException e) {
			Debug.e(e);
		}
		return true;
	} else {
		return false;
	}
}
 
Example 16
Source File: BaseBitmapTextureAtlasSourceDecorator.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
	final Bitmap bitmap = this.onLoadBitmap(pBitmapConfig, true);

	final Canvas canvas = new Canvas(bitmap);
	try {
		this.onDecorateBitmap(canvas);
	} catch (final Exception e) {
		Debug.e(e);
	}
	return bitmap;
}
 
Example 17
Source File: SocketUtils.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
public static final void closeSocket(final Socket pSocket) {
	if(pSocket != null && !pSocket.isClosed()) {
		try {
			pSocket.close();
		} catch (final IOException e) {
			Debug.e(e);
		}
	}
}
 
Example 18
Source File: BaseGameActivity.java    From tilt-game-android with MIT License 5 votes vote down vote up
private void acquireWakeLock(final WakeLockOptions pWakeLockOptions) {
	if (pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
		ActivityUtils.keepScreenOn(this);
	} else {
		final PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
		this.mWakeLock = pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE, Constants.DEBUGTAG);
		try {
			this.mWakeLock.acquire();
		} catch (final SecurityException pSecurityException) {
			Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !", pSecurityException);
		}
	}
}
 
Example 19
Source File: EngineRenderer.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public void onDrawFrame(final GL10 pGL) {
	synchronized(GLState.class) {
		if (this.mMultiSampling && this.mConfigChooser.isCoverageMultiSampling()) {
			final int GL_COVERAGE_BUFFER_BIT_NV = 0x8000;
			GLES20.glClear(GL_COVERAGE_BUFFER_BIT_NV);
		}

		try {
			this.mEngine.onDrawFrame(this.mGLState);
		} catch (final InterruptedException e) {
			Debug.e("GLThread interrupted!", e);
		}
	}
}
 
Example 20
Source File: ITextureAtlas.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onTextureAtlasSourceLoaded(final ITextureAtlas<T> pTextureAtlas, final T pTextureAtlasSource) {
	Debug.e("Loaded TextureAtlasSource. TextureAtlas: " + pTextureAtlas.toString() + " TextureAtlasSource: " + pTextureAtlasSource.toString());
}