When I switch screens it lags and takes a really long time to load it on android, but on desktop launcher it does it instantly.
An example of a screen that takes a long time load is the level screen, it goes there from the main menu.
This is the code in the LevelScreen it takes a really long time load this, Is there any reason for this?
public class LevelScreen extends MenuBase {
private GameMain mGameMain;
public LevelScreen(GameMain main) {
super(main, GameInfo.LEVEL_SCREEN_NAME);
this.mGameMain = main;
main.ply.showAds(false);
}
@Override
protected Actor createActors() {
Table container = new Table();
container.setDebug(GameInfo.TABLE_DEBUG);
container.setFillParent(true);
container.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(AssetPaths.BLUE_BACKGROUND))));
Table table = new Table();
table.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(AssetPaths.BLUE_BACKGROUND))));
table.setDebug(GameInfo.TABLE_DEBUG);
final ScrollPane scroll = new ScrollPane(table, uiSkin);
table.pad(GameInfo.HUD_HEIGHT).defaults().space(10);
for (int i = 1; i < 8; i++) {
table.row();
final TextButton button = new TextButton("Level " + i, uiSkin, SkinStylePath.LIGHT_BUTTON_LONG);
table.add(button).padRight(50f);
button.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
System.out.println("click " + x + ", " + y);
}
});
System.out.println(GameManager.getInstance().scoreUnlockList(i));
System.out.println("GameManager.getInstance().mGameData.getUpToWhichLevelIsUnlocked() = " + GameManager.getInstance().mGameData.getUpToWhichLevelIsUnlocked() +
"\n GameManager.getInstance().mGameData.isLevel7Unlocked() " + GameManager.getInstance().mGameData.isLevel7Unlocked());
if (GameManager.getInstance().mGameData.getUpToWhichLevelIsUnlocked() < i) {
// for the levels we haven't unlocked write this next to it.
table.add(new Label("get over " + GameManager.getInstance().scoreUnlockList(i) + " points to unlock this level", uiSkin, SkinStylePath.ARVO_WHITE_WITH_BLACK_OUTLINE_22));
//disable all the buttons that we haven't unlocked that level for
button.setDisabled(true);
}
final int finalI = i;
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
clickSound(randomNumberGenerator()).play(GameManager.getInstance().mGameData.getSoundFxVolume());
playLevel(finalI, button);
}
});
}
scroll.setFlickScroll(true);
scroll.setFadeScrollBars(true);
scroll.setSmoothScrolling(true);
container.add(scroll).expand().fill();
container.row();
return container;
}
@Override
protected void createAnotherActor(Stage mStage) {
Texture handTexture;
handTexture = mAssetManager.get(AssetDescriptors.HAND);
Image handImage = new Image(handTexture);
handImage.setPosition(560, 100);
SequenceAction sequenceAction = new SequenceAction(GameManager.getInstance().handMoveSequence(0.3f, false), Actions.moveTo(560f, 560f, 0.8f));
handImage.addAction(sequenceAction);
if (GameManager.getInstance().mGameData.getUpToWhichLevelIsUnlocked() >= 3) {
mStage.addActor(handImage);
}
}
void playLevel(int levelNumber, TextButton levelTextButton) {
GameManager.getInstance().selectLevel(levelNumber);
mGameMain.setScreen(new NutritionQuiz(mGameMain, levelTextButton.getText().toString()));
}
@Override
public void show() {
}
}