2017-02-08 8 views
1

私のクイズゲームに質問データベースなどのローカルデータベースファイルを使用します。私は公式のココスの作成者サイトまたはフォーラムでチュートリアルを見つけることができません。 Cですでに問題
Use database (such as sqlite) with cocos2d-x
を解決しかし、私はC++cocos creator javascriptでsqliteデータベースを使用する方法

に貧弱だから、私はJavaScriptでソリューションを必要とココス作成者に

cc.Class({ 
extends: cc.Component, 

properties: { 
    // foo: { 
    // default: null,  // The default value will be used only when the component attaching 
    //       to a node for the first time 
    // url: cc.Texture2D, // optional, default is typeof default 
    // serializable: true, // optional, default is true 
    // visible: true,  // optional, default is true 
    // displayName: 'Foo', // optional 
    // readonly: false, // optional, default is false 
    // }, 
    // ... 
}, 

// use this for initialization 
onLoad: function() { 

}, 

onbuttnclick: function(){ 
    //var test = new cc.Scene('test'); 
    //cc.director.pushScene(test); 
    cc.director.loadScene('helloworld'); 
    //cc.director.popScene(); 
}, 

// called every frame, uncomment this function to activate update callback 
// update: function (dt) { 

// }, 
}); 

デフォルトのスクリプトではJavaScript、以下でそれを使用したい++それはH5などのローカル保存されたAPIを持ってcocoscreatorで

答えて

1

パラメータを取得localstorage.set私はAPIを忘れてしまったが、ポイントは、それH5のlocalStorage APIのような、それは

+0

ネイティブ卿の自動車使用のsqliteのだろうということです、缶キ​​ー値とキーですあなたはpリース後のサンプルコード –

+1

申し訳ありませんが、最初のコマンドです。私はコードを使わずに返信するために電話を使うからです。今度は次のように使用できるコードをチェックします: 'cc.sys.localStorage.setItem(" key "、" value "); let value = cc.sys.localStorage.getItem( "key"); '任意のJSON.stringify(JSONObject)を格納できます。 localStorageの値として使用し、クロムのネイティブまたはローカルキャッシュ内のディスク上のデータファイルを削除しないと、ゲームを再起動するときにいつでも取得できます。 –

関連する問題