First of all when writing wallpaper it is best to set its priority to 1. The value should be an integer with higher integers given higher priority. You want your wallpaper to have low priority. This is set in the AndroidManifest.xml file. Here is the snippet with the change.
<intent-filter android:priority="1"> <action android:name="android.service.wallpaper.WallpaperService"/> </intent-filter>There are several other modifications that need to be made to keep a livewallpaper from draining the battery. Secondly I changed ParticleSystem to BatchedSpriteParticleSystem. From what I understand this will increase performance without compromising on the battery life. You need to change the declaration of course.
final BatchedSpriteParticleSystem particleSystem = new BatchedSpriteParticleSystem(new PointParticleEmitter (mParticleX, mParticleY), mParticleMinRate, mParticleMaxRate, mParticleMax, this.mFlowerTextureRegion, this.getVertexBufferObjectManager());Then you need to replace every instance of <Sprite> with <UncoloredSprite> like this:
particleSystem.addParticleInitializer(new BlendFunctionParticleInitializer <UncoloredSprite>(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE));The third change I made was to disable the accelerometer when the game was paused. Then of course onResume you will need to enable it.
@Override public void onResumeGame() { super.onResumeGame(); this.enableAccelerationSensor(this); } protected boolean disableAccelerationSensor() { return this.mEngine.disableAccelerationSensor(this); } @Override public void onPauseGame() { super.onPauseGame(); this.disableAccelerationSensor(); }I have committed all changes to github at https://github.com/RealWorldApplications/LiveWallpaperExample.
Hello,
ReplyDeletethank you for tutorial...
I also create live wallpaper using AndEngineExtension..
I want to implement touch effect in my live wallpaper, now i'm using IOnSceneTouchListener, but it only handle tap event..
do You know how to handling touch event? like on touch began, touch moved, and touch ended..
I'll appreciate Your help,
thanks in advance..
Thankyou so much for sharing useful knowledge. I bookmarked your blog to see more tutorials. offshore software development
ReplyDeleteHey Carol, just saw your comment about my Glimmer wallpaper. Glad posting the code could help you in your development!
ReplyDeleteEric