android - AngEngine 动态壁纸

标签 android andengine live-wallpaper

AngEngine 使用 org.anddev.andengine 库和 Wallpaper 扩展 lib,我想使用计时器不时更新场景背景或使用更新程序,但找不到任何帮助。

我正在使用:

private void createSpriteSpawnTimeHandler()
{
    scene.registerPostFrameHandler(spriteTimerHandler = new TimerHandler(0.02f, new ITimerCallback() {
        @Override
        public void onTimePassed(TimerHandler arg0) {
            // TODO Auto-generated method stub
            scene.setBackground(new SpriteBackground(new Sprite(0,0,
                    HummingBirdLiveWallpaper.CAMERA_WIDTH,
                    HummingBirdLiveWallpaper.CAMERA_HEIGHT,
                    mCigaretteTextureRegion)));
        }

    }));
    spriteTimerHandler.onUpdate(0.02f);
}

并从 onLoadScene() 调用,但它不会更改背景。 请帮助我,如果有任何例子请告诉我。

最佳答案

我有类似的情况,对我有用的是更改“mCigaretteTextureRegion”。 它与 andengine 示例“更新纹理”中使用的技术相同 https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/UpdateTextureExample.java

您还可以获得不需要每次都创建新的 SpriteBackground 的额外好处。

关于android - AngEngine 动态壁纸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15175535/

相关文章:

java - 添加到数组或链表时游戏崩溃

android - 将SWF移植到Android动态壁纸的步骤

android - 如何设置 Android 动态壁纸图标(又名 "thumbnail")

android - 无法获取 Crashlytics 中 native 崩溃的堆栈跟踪

Android 简单定时器/Timertask 问题

android - 为什么在Web View 中渲染组件的速度变慢?

android - 在android中使用OpenGL在动态壁纸上绘制纹理

android - 如何将 View 与 TextView 中的文本垂直对齐?

java - 使用 AndEngine 时的 onResumeGame() NullPointerException

android - 在后台加载 - AndEngine GLES2