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
| public boolean loaded = false;
public WorldMap() { load(); }
public void load() { if (!loaded) { loaded = true; } else if (loaded) { return; } }
public void update() { }
public void run() { try { update(); Thread.sleep(400L); } catch(Exception e) { e.printStackTrace(System.err); } } |
Basically create a boolean of 'loaded', set it to false by default.
In the constructor of your program/launch point of the class where you're rendering tiles call the 'load()' method.
And by default, if you set 'loaded = true' in that method after loading, next time (If called in a game loop/run method), it's just going to return, it isn't going to load that method again.
Hope it helps mate, once again sloppy code

.