blob: a410a12c199c74318cb50e7d268a0ebff60fa7fa (
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
|
package com.ilotterytea.maxoning;
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.ilotterytea.maxoning.player.MaxonPlayer;
import com.ilotterytea.maxoning.screens.AssetLoadingScreen;
import com.ilotterytea.maxoning.utils.serialization.GameDataSystem;
import java.io.IOException;
public class MaxonGame extends Game {
public SpriteBatch batch;
public AssetManager assetManager;
public Preferences prefs;
private static MaxonGame instance;
public static MaxonGame getInstance() {
if (instance == null) {
instance = new MaxonGame();
}
return instance;
}
@Override
public void create () {
batch = new SpriteBatch();
prefs = Gdx.app.getPreferences("Maxoning");
if (!GameDataSystem.exists()) {
try {
GameDataSystem.SaveData(new MaxonPlayer());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
assetManager = new AssetManager();
this.setScreen(new AssetLoadingScreen(this));
}
@Override
public void render () {
super.render();
}
@Override
public void dispose () {
batch.dispose();
for (String name : assetManager.getAssetNames()) {
assetManager.unload(name);
}
assetManager.dispose();
instance.dispose();
}
}
|