官方文档部分解释
1)By default in libgdx, the rendering thread calls the render() method of your ApplicationListener class continuously, with a frequency that depends on your hardware (30-50-80 times per second).
If you have many still frames in your game (think about a card game) you can save precious battery power by disabling the continuous rendering, and calling it only when you really need it.
All you need is put the following lines in your ApplicationListener's create() method
Gdx.graphics.setContinuousRendering(false);
Gdx.graphics.requestRendering();
The first line tells the game to stop calling the render() method automatically. The second line triggers the render() method once. You have to use the second line wherever you want the render() method to be called.
在libgdx中,默认是由render thread不断地调用render()方法。如果你不想render()方法被自动的调用,这时候你可以Gdx.graphics.setContinuousRendering(false);//不再自动调用render()方法
在不再自动调用之后,你应该加一句
Gdx.graphics.requestRendering();//手动调用render()方法
2)
If continuous rendering is set to false, the render() method will be called only when the following things happen.
- An input event is triggered //input event发生
- Gdx.graphics.requestRendering() is called //requestRendering()方法被调用
- Gdx.app.postRunnable() is called //postRunnable()方法被调用
二、应用举例
package com.example.groupactiontest;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Input.Peripheral;
import com.badlogic.gdx.graphics.GL10;
public class MyGame implements ApplicationListener {
int counter = 1;
@Override
public void create() {
Gdx.graphics.setContinuousRendering(false);//不再自动调用render()方法
Gdx.graphics.requestRendering();//手动调用render()方法
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
System.out.println("------------->" + counter++);
}
@Override
public void resize(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
}
四、源码下载
http://download.csdn.net/detail/caihongshijie6/7052325