我的问题是:TextureAtlas应该在调用时加载每个页面图像,以便它在加载后影响运行?或者至少我是否可以知道它何时会运行,正常绘制?
非常感谢您的回答!
显而易见的是这里的代码,但它很简单:
public class App extends Game {
@Override
public void create() {
Gdx.app.log( this.LOG, "Creating game" );
fpsLogger = new FPSLogger();
setScreen( new IntroScreen(this) );
}
}
IntroScreen:
public class IntroScreen implements Screen {
@Override
public void resize(
int width,
int height )
{
super.resize( width, height );
Gdx.app.log("IntroScreen", "Resize start: " );
atlas = new TextureAtlas( Gdx.files.internal( "image-atlases/pages-info.atlas" ) );
Gdx.app.log("IntroScreen", "Resize finished: " );
}
@Override
public void render(
float delta )
{
Gdx.gl.glClearColor( 0f, 0f, 0f, 1f );
Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
Gdx.app.log( "IntroScreen", "Delta: " + delta );
// stage is empty
stage.act( delta );
stage.draw();
}
}
这是LogCat的输出:
08-09 01:09:53.689: I/IntroScreen(9757): Resize start:
08-09 01:09:54.004: I/IntroScreen(9757): Resize finished:
08-09 01:09:54.009: I/IntroScreen(9757): Delta: 0.10668343
08-09 01:09:54.009: I/IntroScreen(9757): Delta: 0.1037551
08-09 01:09:54.024: I/IntroScreen(9757): Delta: 0.1006427
08-09 01:09:54.039: I/IntroScreen(9757): Delta: 0.09953054
08-09 01:09:54.054: I/IntroScreen(9757): Delta: 0.099971004
08-09 01:09:54.074: I/IntroScreen(9757): Delta: 0.009933725
08-09 01:09:54.089: I/IntroScreen(9757): Delta: 0.012701442
08-09 01:09:54.104: I/IntroScreen(9757): Delta: 0.015878525
08-09 01:09:54.124: I/IntroScreen(9757): Delta: 0.016689042
08-09 01:09:54.144: I/IntroScreen(9757): Delta: 0.017476525
08-09 01:09:54.159: I/IntroScreen(9757): Delta: 0.017719833
08-09 01:09:54.174: I/IntroScreen(9757): Delta: 0.017750284
08-09 01:09:54.189: I/IntroScreen(9757): Delta: 0.017803017
...
感谢您的帮助。
答案 0 :(得分:5)
在Android上,在最后5帧中对增量时间进行平滑(平均)。如果加载TextureAtlas
(或任何其他资源)的过程会使该帧花费更长时间(最有可能),那么您将看到接下来的5个左右帧的更高增量时间。如果您想要未平滑的增量,可以尝试getRawDeltaTime
。当然,您必须忽略传递给render方法的delta时间,并在render方法的开头从Gdx.graphics.getRawDeltaTime()
获取原始delta。