添加和存储高分

时间:2015-12-29 02:13:58

标签: actionscript-3 flash

我想在我的安卓游戏中添加一个高分。我想在它们返回时添加它并存储。我该如何解决这个问题? 这是我想要的框架的代码!

lblScore.text = String(score);
gameOver.addEventListener(TouchEvent.TOUCH_TAP, End);
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; 


function End(event:TouchEvent): void {
    gotoAndPlay(1);
}

stage.removeEventListener(TouchEvent.TOUCH_TAP, End);

function refreshScores():void {
    lblScore.text = String(score);
    score++;
}

1 个答案:

答案 0 :(得分:1)

您可以使用SharedObject

var localstorage:SharedObject = SharedObject.getLocal("anyname");

//Save the data to the SharedObject
localstorage.data.score = 100;
//Commit the save
localstorage.flush();

//Get data in the SharedObject, but check to see if it exists
if (localstorage.data.score != undefined){
    //if SharedObject exists so display the data
    trace(localstorage.data.score);
}else{
    //SharedObject does not exists.
}

//If you want to clear the ShareObject
localstorage.clear();

如果您想以数据库方式保存,请使用SQLite