【问题标题】:How can I stop and resume my implemented ApplicationListener class?如何停止和恢复我实现的 ApplicationListener 类?
【发布时间】:2013-03-25 15:42:21
【问题描述】:

我有类 WallpaperAndDream 实现 ApplicationListener。全部由 ligdx(动态壁纸和白日梦)实现。 这里是创建和渲染的方法:

public void create() {
    camera = new OrthographicCamera(width, height);
    camera.position.set(width / 2, height / 2, 0);
    bg.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    batch = new SpriteBatch();
    Gdx.graphics.setContinuousRendering(false);
}


public void render() {
    GL10 gl = Gdx.graphics.getGL10();

    gl.glClearColor(bg_red, bg_green, bg_blue, 1f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera = new OrthographicCamera(width, height);
    camera.position.set(width / 2, height / 2, 0);
    camera.update();
    camera.apply(Gdx.gl10);
    batch.setProjectionMatrix(camera.combined);

    batch.begin();
    BitmapFont font;
    font = new BitmapFont();
    font.setScale(3.0f);
    font.setColor(Color.RED);

    font.draw(batch, BouncerDaydream.maxLight+" "+BouncerDaydream.thisLight, 100, 100);

    batch.end();
    try {
        Thread.sleep(update_interval);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Gdx.graphics.requestRendering();
}

当我在动态壁纸之后有白日梦时,它会交替绘制,但我需要在这段时间内暂停(或停止)白日梦并在它可见时恢复它,我该怎么做? 提前谢谢!

【问题讨论】:

    标签: android rendering libgdx live-wallpaper


    【解决方案1】:

    我不确定我是否理解您的问题,但要创建动态壁纸,您应该扩展 AndroidLiveWallpaperService,而对于 Daydreams,应该扩展 AndroidDaydream。

    此页面有更多信息:https://github.com/libgdx/libgdx/wiki/Starter-classes-&-configuration

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      • 2020-11-05
      • 2011-03-06
      相关资源
      最近更新 更多