blob: 67b4a0e942dc073a093dfe99a262657c04529c50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package kz.ilotterytea.maxon;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import de.tomgrill.gdxdialogs.core.GDXDialogs;
import de.tomgrill.gdxdialogs.core.GDXDialogsSystem;
import kz.ilotterytea.maxon.pets.PetManager;
import kz.ilotterytea.maxon.screens.SplashScreen;
import kz.ilotterytea.maxon.utils.GameUpdater;
import kz.ilotterytea.maxon.utils.I18N;
public class MaxonGame extends Game {
public SpriteBatch batch;
public ShapeRenderer shapeRenderer;
public AssetManager assetManager;
public Preferences prefs;
public I18N locale;
private PetManager petManager;
private GDXDialogs dialogWindows;
private static MaxonGame instance;
public static MaxonGame getInstance() {
if (instance == null) {
instance = new MaxonGame();
}
return instance;
}
public PetManager getPetManager() {
return petManager;
}
public GDXDialogs getDialogWindows() {
return dialogWindows;
}
@Override
public void create () {
// Check the latest version
new GameUpdater().checkLatestUpdate();
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
prefs = Gdx.app.getPreferences(MaxonConstants.GAME_APP_PACKAGE);
locale = new I18N(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json"));
prefs.putInteger("width", Gdx.graphics.getWidth());
prefs.putInteger("height", Gdx.graphics.getHeight());
prefs.flush();
Gdx.graphics.setVSync(prefs.getBoolean("vsync", true));
if (prefs.getBoolean("fullscreen", false)) { Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); }
assetManager = new AssetManager();
petManager = new PetManager(assetManager);
dialogWindows = GDXDialogsSystem.install();
this.setScreen(new SplashScreen());
}
@Override
public void render () {
super.render();
}
@Override
public void dispose () {
batch.dispose();
for (String name : assetManager.getAssetNames()) {
assetManager.unload(name);
}
assetManager.dispose();
instance.dispose();
}
}
|