// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { // foo: { // // ATTRIBUTES: // default: null, // The default value will be used only when the component attaching // // to a node for the first time // type: cc.SpriteFrame, // optional, default is typeof default // serializable: true, // optional, default is true // }, // bar: { // get () { // return this._bar; // }, // set (value) { // this._bar = value; // } // }, }, // LIFE-CYCLE CALLBACKS: onLoad() { this.info = cc.find("info"); this.Button = cc.find("New Button"); UtilsPrefabs.setOn(this.Button,function () { cc.director.loadScene('MyCityScene - 004', function () { this.progressTag = false; }.bind(this)); }.bind(this)) cc.audioEngine.stopAll(); // this.setInfo("停止声音"); this.progressTag = false; this.oldprogressTag = -99; cc.loader.onProgress = function (completeCount, totalCount) { if (this.progressTag) { this.progress = (1 * completeCount / totalCount).toFixed(1); // console.log("进度条",this.progress + '%',this.progressNode); if (this.progressNode != null) { this.progressNode.getComponent(cc.ProgressBar).progress = this.progress; } } }.bind(this); // console.log('准备去游戏 准备跳转到下个页面'); // this.setInfo("准备加载背景"); UtilsPrefabs .init(this.node) .addPrefabs(UtilsPrefabs.PrefabsName[2], null, function (node) { // this.setInfo("加载背景完成 去微信登录"); UtilsWX.wxgameLogin(function (res) { console.log('获取玩家信息 准备跳转到下个页面',res); // this.setInfo("获取到 用户信息"+res); UtilsWX.wxlogin(res, function () { // this.setInfo("访问后台登陆 游戏"+res); UtilsWX.removeUserInfoButton(); this.showLoadDialog(); }.bind(this), function () { // console.log('访问自己后台服务器登录账号错误'); // this.setInfo("访问自己后台服务器登录账号错误"); }.bind(this)); }.bind(this)) if (cc.sys.platform != cc.sys.WECHAT_GAME) { // this.setInfo("加载 dialog 准备使用本地id 登录游戏"); this.showLoadDialog(); } }.bind(this)); // node.y = -200; // // var GivePrize = UtilsPrefabs.getNode("GivePrize",node); // //转 // var Sunshine = UtilsPrefabs.getNode("Sunshine",GivePrize); // //物品 // var Rewards = UtilsPrefabs.getNode("Rewards",GivePrize); // //关闭按钮 // var close = UtilsPrefabs.getNode("close",node); // // Rewards.getComponent(cc.Sprite).spriteFrame = this.getNode("ItemSprite",this.TodayNode).getComponent(cc.Sprite).spriteFrame // Rewards.scale = 2; // // Sunshine.stopAllActions(); // var repeat = cc.repeatForever(cc.rotateBy(5.0, 360)); // Sunshine.runAction(repeat); // this.EveryDaySignView.active=false; // // UtilsPrefabs.setOn(close,function () { // // // this.ManageUI.getComponent("ManageUI").onButtonEvent_EveryDay_Close(); // UtilsPrefabs.setOff(close); // UtilsPrefabs.removePrefabs(this.EveryDaySignContainer,node.name); // }.bind(this)); // // UtilsPrefabs // .init(this.EveryDaySignContainer) // .addPrefabs(UtilsPrefabs.PrefabsName[0],null,function (node) { // node.y = -200; // var gosharebtn = UtilsPrefabs.getNode("gosharebtn",node); // var img1 = UtilsPrefabs.getNode("img1",node); // var NewLabel1 = UtilsPrefabs.getNode("New Label",img1); // var img2 = UtilsPrefabs.getNode("img2",node); // var NewLabel2 = UtilsPrefabs.getNode("New Label",img2); // NewLabel1.getComponent(cc.Label).string = 'x'+GlobalD.GameData.signInGive[0]; // NewLabel2.getComponent(cc.Label).string = 'x'+GlobalD.GameData.signInGive[1]; // // // UtilsPrefabs.setOn(gosharebtn,function () { // console.log("点击分享按钮"); // UtilsWX.sharebtn(); // UtilsPrefabs.setOff(gosharebtn); // UtilsPrefabs.removePrefabs(this.EveryDaySignContainer,node.name); // GlobalD.GameData.PlusGolden(GlobalD.GameData.signInGive[0]); // GlobalD.GameData.PlusDiamond(GlobalD.GameData.signInGive[1]); // }.bind(this)) // }.bind(this)); // this.initTest(); }, setInfo : function(string){ this.info.getComponent(cc.Label).string +=string+"^_^"; }, showLoadDialog: function () { // this.setInfo("获取游戏的网络数据"); //开局初始化的数据 this.getNetworkData((res) => { cc.log('初始化数据1',res); // this.setInfo("获取成功"+res.code); //获取网络数据后处理 if (res.code == 0) { //记录读取的数据到内存里面 userData.readData = res.data.userdata; } else { userData.readData = null; } UtilsPrefabs .init(this.node) .addPrefabs(UtilsPrefabs.PrefabsName[3], null, function (node) { node.y = -500; var bgbar = UtilsPrefabs.getNode("bgbar", node); this.progressNode = UtilsPrefabs.getNode("progress", bgbar); // this.progressNode.getComponent(cc.ProgressBar).progress = this.progress; this.progressTag = true; }.bind(this)); // cc.game.off(cc.game.EVENT_HIDE); // cc.game.off(cc.game.EVENT_SHOW); // this.setInfo("真的是去 下个页面了"+res.code); // this.Button.active = true; // return; console.log("准备开始游戏了"); cc.director.loadScene('MyCityScene - 004', function () { this.progressTag = false; }.bind(this)); }); // cc.director.loadScene('NewScene',function () { // this.progressTag = false; // // }.bind(this)); }, // start() { // }, // update (dt) {}, getNetworkData: function (callback) { var data = []; data["openid"] = userData.openId; // data["userdata"] = JSON.stringify(datas); httpUtils.Post(httpUtils.getUserData, data, function (data) { callback(data); }.bind(this), function (data) { // console.log("失败", data); callback(data); }.bind(this)); }, });