I’ve made a StorageManager class which saves the best score. Everything works fine until I close the app and reopen it, the class doesn’t save the best score after the app is closed.
Here is StorageManager.hx:
package utils;
import openfl.net.SharedObject;
class StorageManager {
public var score: UInt;
public var bestScore: UInt;
private var localStorage: SharedObject;
public function new() {
localStorage = SharedObject.getLocal("around_data");
}
public function manageScore(_score: UInt): Void {
score = _score;
if (localStorage.data.bestScore == null) {
localStorage.data.bestScore = score;
localStorage.flush();
} else {
var _bestScore = localStorage.data.bestScore;
if (_bestScore < score) {
localStorage.data.bestScore = score;
localStorage.flush();
}
}
bestScore = localStorage.data.bestScore;
}
Passing both arguments doesn’t solve the problem.
No, I’m not using -Dlegacy, but if I use it the score is saved but now all the texts are left centered with the default font and the Sprites have a weird behaviour.
Strange. I’m using legacy, because it is stable. TextFormatAlign.CENTER works fine for me in legacy, also everything is fine with sprites.
(legacy don’t work well on x86 androids, but work fine on arm)
I use textField.embedFonts = true; to be able to use custom fonts. Other (textFormat.align , textFormat.size) works fine for me:
I don’t remember exact reason why I use textField.defaultTextFormat = textFormat; after setting all properties on textField, but before setting text. Maybe it is related, maybe not.