stackoverflowers and other good people, I have one issue with which I don't know how to solve after a two days of trying: I have libgdx project (I'm using stages and actors, but that's not important now) where I add to comments everything not useful and problem is simple:
My question is: TextureAtlas is supposed to load every page image when it's called so why it affects running after it has been load? Or at least whether can I know when it will be running, drawing normally?
Really thanks for your answer!
Obivously here's code, but it's simple as this:
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();
}
}
And here is output from 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
...
Thanks for any help.
On Android, the delta times are smoothed (averaged) over the last 5 frames. If the process of loading a TextureAtlas
(or any other assets) makes that frame take longer (as it most likely will), then you'll see higher delta times for the next 5 or so frames. You might try getRawDeltaTime
if you want the unsmoothed deltas. Of course, you'll have to ignore the delta time which is passed into the render method, and obtain the raw delta from Gdx.graphics.getRawDeltaTime()
at the beginning of your render method.