AssetManager caches saved game, despite change to file

I’m saving the game state using something like this:

[java]
final File file = new File(home+File.separator+“SavedGames”+File.separator+GAME_NAME+".j3o");
BinaryExporter exporter = BinaryExporter.getInstance();
try {
exporter.save(gameStateNode, file);
…[/java]

And then reloading it later with something like this:
[java]
final BinaryImporter importer = BinaryImporter.getInstance();
importer.setAssetManager(assetManager);
gameStateNode = (Node) assetManager.loadModel(File.separator
+“SavedGames”+File.separator+GAME_NAME+".j3o");
[/java]

Printing the file timestamps, I can see that it gets saved, but if I re-load it several time, it seems it remembers the first file content, and doesn’t re-read it. This makes sense, since assets really should be static, and this saves IO, but in this case, I always want to get the “new content”. Am I forced to invent a new file name every time, and delete the old one? I don’t see any “force reload”, or any “clear cache” on the asset manager.

OK, worked it out myself. :slight_smile: I have to get past the AssetManager interface, into the concrete class, like this:

[java]((DesktopAssetManager) assetManager).deleteFromCache(new ModelKey(key));[/java]

1 Like