如何使用LibGDX制作Android动态壁纸?

4
我想制作Android动态壁纸,希望使用LibGDx。我找到了这个信息:http://www.badlogicgames.com/wordpress/?p=2652。但是,在将代码复制到我的壁纸后,Eclipse显示错误。有人知道如何使用LibGDx制作壁纸吗?Eclipse显示以下信息:“MyApplicationListener无法解析为类型”?有3个快速修复可用:1.创建类MyApplicationListener;2.更改为“ApplicationListener”(com.badlogic.gdx);3.修复项目设置。选择第二种修复后,Eclipse显示另一个错误:“无法实例化类型ApplicationListener”。在HaMMeReD的帮助下,我解决了问题。我的Android项目代码如下:
public class MainActivity extends AndroidLiveWallpaperService {

    @Override
    public ApplicationListener createListener(boolean isPreview) {
        // TODO Auto-generated method stub
        return new SexyWomen();// here should be wrote name of class form main LibGDx project
    }

    @Override
    public AndroidApplicationConfiguration createConfig() {
        // TODO Auto-generated method stub
        return new AndroidApplicationConfiguration();
    }

    @Override
    public void offsetChange(ApplicationListener listener, float xOffset, float yOffset, float xOffsetStep, float yOffsetStep,
            int xPixelOffset, int yPixelOffset) {
        // TODO Auto-generated method stub
        Gdx.app.log("LiveWallpaper", "offset changed: " + xOffset + ", " + yOffset);

    }

}

1
在这里提到发生错误,但未能发布确切的错误消息是让自己不受欢迎的好方法。 - Chris Stratton
1个回答

3
把你的代码恢复到原来的状态。
选择第三个选项进行快速修复。
它应该包括在您的构建路径中的Main Gdx项目,并修复该错误。
手动转到Java-Build-Path / Projects选项卡并添加您的Gdx项目。
您的后端项目需要访问您的主要gdx项目,以便找到该类。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接