/** * 游戏所需宏定义 */ window.WINSIZE = cc.winSize; window.heightoffest = null; window.STAR_WIDTH = 10; //星星间隔宽度 window.STAR_HEIGHT = 10;//星星间隔高度 window.STAR_SIZE_WIDTH = 62;//星星尺寸 window.STAR_CHESS_SCALE = 0.98;//星星缩放值 window.tipdelayTime = 0.6; window.CHESSMAN_LEVEL = 4; window.HANGTAG = 1212; window.GUIDELAYERTAG = 1213; window.HANDTAG = 1214; window.TIPFONTTAG = 1215; window.SECONDLAYERTAG = 1216; window.boxremovesingletime = 0.12; window.cleardelayTime = 0.1; window.chessmovetime = 0.2; window.ignoreposition = cc.v2(460 * WINSIZE.width / 640, 300); window.cleardelaytime = 0.1; window.Hkey = 0.92; window.GameState = { STATE_RUN: 1, STATE_FAILD: 2, STATE_STOP: 3, STATE_PAUSE: 4 }; window.TouchState = { TOUCH_TRUE: 1, TOUCH_FAILD: 2, }; window.coinNum = 0; window.playeSound = 1; window.playeMusic = 1; window.localDataItem = { coinNum: "coinNum", //金币数量 playeSound: "playeSound", playeMusic: "playeMusic", gameScore: "gameScore", gameLastscore: "gameLastscore", gameLevel: "gameLevel", gameTarget: "gameTarget", gameHang: "gameHang", gameStepnumber: "gameStepnumber", gameChesspad: "gameChesspad", gameChessid: "gameChessid", gameIssaved: "gameIssaved", gameGuide: "gameGuide", }; window.isFirstInGame = true; window.PROPPRICE = [10, 50]; var gameLocalData = gameLocalData || {} //游戏本地数据保存 gameLocalData = { _score: 0, //分数 _level: 0, //关数 _lastscore: 0, //上关分数 _target: 0, //目标 _hang: 0, //行数 _stepnumber: 0, //步数 _chesspad: "", //棋盘 _chessid: "", //可供选择的id _issaved: 0, //是否已保存数据 init: function () { this._score = 0; this._level = 0; this._lastscore = 0; this._target = 0; this._hang = 0; this._stepnumber = 0; this._chesspad = ""; this._chessid = ""; this._issaved = 0; }, save: function (manager) { if (!manager) return; this.init(); this._score = manager.getScore(); this._level = manager.getLevel(); this._lastscore = manager._lastLevelScore; this._target = manager.getTarget(); var chessinfo = manager._chessInfo; console.log("chessinfo-: ", chessinfo); console.log("_level-: ", this._level); var map = ""; for (var i in chessinfo) { map += chessinfo[i].toString(); } this._chesspad = map; this._issaved = 1; this.dataSave(); }, clear: function () { this.dataClear(); }, getSaveData: function () { this.dataWrite(); }, dataSave: function () { cc.sys.localStorage.setItem(localDataItem.gameScore, this._score.toString()); cc.sys.localStorage.setItem(localDataItem.gameLastscore, this._lastscore.toString()); cc.sys.localStorage.setItem(localDataItem.gameLevel, this._level.toString()); cc.sys.localStorage.setItem(localDataItem.gameTarget, this._target.toString()); cc.sys.localStorage.setItem(localDataItem.gameHang, this._hang.toString()); cc.sys.localStorage.setItem(localDataItem.gameStepnumber, this._stepnumber.toString()); cc.sys.localStorage.setItem(localDataItem.gameChesspad, this._chesspad.toString()); cc.sys.localStorage.setItem(localDataItem.gameChessid, this._chessid.toString()); cc.sys.localStorage.setItem(localDataItem.gameIssaved, this._issaved.toString()); }, dataWrite: function () { this._score = parseInt(cc.sys.localStorage.getItem(localDataItem.gameScore)); this._lastscore = parseInt(cc.sys.localStorage.getItem(localDataItem.gameLastscore)); this._level = parseInt(cc.sys.localStorage.getItem(localDataItem.gameLevel)); this._target = parseInt(cc.sys.localStorage.getItem(localDataItem.gameTarget)); this._hang = parseInt(cc.sys.localStorage.getItem(localDataItem.gameHang)); this._stepnumber = parseInt(cc.sys.localStorage.getItem(localDataItem.gameStepnumber)); this._issaved = parseInt(cc.sys.localStorage.getItem(localDataItem.gameIssaved)); this._chesspad = cc.sys.localStorage.getItem(localDataItem.gameChesspad); this._chessid = cc.sys.localStorage.getItem(localDataItem.gameChessid); }, dataClear: function () { this._score = 0; this._lastscore = 0; this._level = 0; this._target = 0; this._hang = 0; this._stepnumber = 0; this._chesspad = ""; this._chessid = ""; this._limitprop = "", this._limitproptag = -1; this._issaved = 0; this.dataSave(); }, }