简体   繁体   English

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

[英]How to make Android Live Wallpaper using LibGDx?

I want to make Android Live Wallpaper. 我想制作Android动态壁纸。 I want to use LibGDx. 我想使用LibGDx。 I found this information: http://www.badlogicgames.com/wordpress/?p=2652 我发现了这个信息: http//www.badlogicgames.com/wordpress/?p = 2652

Unfortunately, ahter copy code to my wallpaper, eclipse show error. 不幸的是,我的壁纸复制代码,eclipse显示错误。

Does anyone knows how to make wallpaper using LibGDx? 有谁知道如何使用LibGDx制作壁纸?

Eclipse shows following information: "MyApplicationListener cannot resolved to a type"? Eclipse显示以下信息:“MyApplicationListener无法解析为某个类型”? There are 3 quick fixes available: 1. create classs MyApplicationListener 2. change to "ApplicationListener" (com.badlogic.gdx) 3. Fix project setup 有3个快速修复:1。创建类MyApplicationListener 2.更改为“ApplicationListener”(com.badlogic.gdx)3。修复项目设置

After choose 2 fix, eclipse shows another error: "Cannot instantiate the type ApplicationListener" 选择2修复后,eclipse显示另一个错误:“无法实例化ApplicationListener类型”

I solved my problem with HaMMeReD's help. 我用HaMMeReD的帮助解决了我的问题。

My code in android project: 我在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);

    }

}

Put your code back the way it was. 把你的代码放回原来的样子。

Choose option 3 for quick fix. 选择选项3进行快速修复。

It should include your Main Gdx project on your build path and fix that error. 它应该在您的构建路径中包含您的Main Gdx项目并修复该错误。

Manually goto Java-Build-Path/Projects tab and add your Gdx project. 手动转到Java-Build-Path / Projects选项卡并添加您的Gdx项目。

Your backend project needs to have access to your main gdx project in order to find that class. 您的后端项目需要访问您的主gdx项目才能找到该类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM