window.RootNode = { soundNode : null, closeButton : null, dialog : null, } window.app = { AETime : 280, //系数数组 punchHitVars : [0.1,0.5,1.2] } cc.Class({ extends: cc.Component, properties: { }, onLoad (){ // httpUtils.Get(httpUtils.httpGetTable,null,function (data) { // console.log("成功",data) // // if (data.code == 0) { // // app.AETime = data.data.AETime; // // app.punchHitVars.push(data.data.firstPunchHitVar); // // app.punchHitVars.push(data.data.secondPunchHitVar); // // app.punchHitVars.push(data.data.thirdPunchHitVar); // // } // }.bind(this),function (data) { // console.log("失败",data) // }.bind(this)); }, _init : function(data){ app.AETime = data.AETime; app.punchHitVars = []; app.punchHitVars.push(data.firstPunchHitVar); app.punchHitVars.push(data.secondPunchHitVar); app.punchHitVars.push(data.thirdPunchHitVar); console.log("设置网络数据",app) }, circleMove (dt) { // 先计算弧度 this.radian -= dt * (this.carSpeed/100); let x = this.circleRadius * Math.cos(this.radian) + this.circleCenter.x; let y = this.circleRadius * Math.sin(this.radian) + this.circleCenter.y; // let angle = 360- 180/Math.PI*this.radian; // this.Earth.angle = angle; //console.log('x = ' + x + ' y = ' + y + ' angle = ' + angle); this.Earth.position = cc.v2(x, y); }, start() { this.TutorialFlag = false; this.Earth = UtilsPrefabs.getNode("Earth", this.node); let EX = this.Earth.position.x; let EY = this.Earth.position.y; // 圆心 this.circleCenter = cc.v2(EX, EY); // 半径 this.circleRadius = 10; // 车速 this.carSpeed = 150; // 弧度 this.radian = 10; this.clickStart = 0; //地球转动动画 //this.schedule(this.circleMove, 0.01); this.soundNode = cc.find("sound"); cc.game.addPersistRootNode(this.soundNode); RootNode.soundNode = this.soundNode; this.c = cc.find("c"); this.closeButton = UtilsPrefabs.getNode("closeButton", this.c); // this.closeButton = cc.find("closeButton"); cc.game.addPersistRootNode(this.c); RootNode.closeButton = this.c; cc.log("数据是啥 login",RootNode); // this.dialog = cc.find("dialog"); // cc.game.addPersistRootNode(this.dialog); // RootNode.dialog = this.dialog; this.scheduleOnce(function () { this.Login_ClipID = this.soundNode.getComponent("soundManage").playLogin(); this.PlayStartToPlayTutorialSound(); }.bind(this),1); // // this.schedule(function () { // this.soundNode.getComponent("soundManage").startToPlayTutorial(); // }.bind(this),7); // this.StartGameTime = setTimeout(function () { // this.soundNode.getComponent("soundManage").playStartGame(); // }.bind(this),10000); utils.redytoLoadScene("main"); utils.redytoLoadScene("Multi_function"); utils.isMobile(function () { Manager.sceneType = 0; Manager.login = this; Manager.getNavigator(); }.bind(this)); this.StarBtn = UtilsPrefabs.getNode("go", this.node); this.Title = UtilsPrefabs.getNode("Title", this.node) let EarthAnim = this.EarthAnim=UtilsPrefabs.getNode("Earth", this.node).getComponent(cc.Animation); //let TitleAnim = this.TitleAnim = UtilsPrefabs.getNode("Title", this.node).getComponent(cc.Animation); //let BeginBtnAnim =this.BeginBtnAnim = go.getComponent(cc.Animation); EarthAnim.on('stop', this.onStop, this); UtilsPrefabs.setOn(this.StarBtn, function () { // utils.toLoadScene("main") this.goMain(); }.bind(this)); }, PlayLoginSound:function() { this.scheduleOnce(function () { this.PlayLoginSchedule(); }.bind(this),10); }, PlayStartToPlayTutorialSound:function() { this.scheduleOnce(function () { this.PlayStartToPlayTutorialSchedule(); }.bind(this),7); }, //播放新手教程 PlayTutorial:function() { if(this.TutorialFlag)return; this.TutorialFlag = true; this.soundNode.getComponent("soundManage").stop(this.Login_ClipID); this.soundNode.getComponent("soundManage").stop(this.StartToPlayTutorial_ClipID); this.unscheduleAllCallbacks(); // this.unschedule(this.PlayLoginSchedule); // this.unschedule(this.PlayStartToPlayTutorialSchedule); this.scheduleOnce(function () { this.Tutorial_ClipID=this.soundNode.getComponent("soundManage").playTutorial(); cc.audioEngine.setFinishCallback(this.Tutorial_ClipID, function () { this.TutorialFlag = false; }.bind(this)); }.bind(this),1); this.scheduleOnce(function () { this.PlayLoginSound(); }.bind(this),35); }, PlayLoginSchedule:function() { this.Login_ClipID=this.soundNode.getComponent("soundManage").playLogin(); this.PlayStartToPlayTutorialSound(); }, PlayStartToPlayTutorialSchedule:function() { this.StartToPlayTutorial_ClipID=this.soundNode.getComponent("soundManage").startToPlayTutorial(); this.PlayLoginSound(); }, goMain : function(){ this.clickStart++; if (this.clickStart > 1) { return; } // this.StarBtn.getComponent(cc.Button).interactable = false; this.unschedule(this.circleMove); let MoveUp = cc.moveBy(0.5,cc.v2(0,1000)).easing(cc.easeIn(10)); let MoveDown = cc.moveBy(0.5,cc.v2(0,-1000)).easing(cc.easeIn(10)); this.Title.runAction(MoveUp); // StarBtn.runAction(MoveDown); let Finish = cc.callFunc(function() { //this.EarthAnim.play(); let _armatureDisplay = this.Earth.getComponent("dragonBones.ArmatureDisplay"); _armatureDisplay.playAnimation("02_1",1); _armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event)=>{ cc.log("complete"); let MoveUp = cc.moveBy(0.5,cc.v2(0,1500)); let Finish2 = cc.callFunc(function() { utils.toLoadScene("main"); }, this); var seq = cc.sequence(MoveUp.easing(cc.easeIn(0.5)), Finish2); this.Earth.runAction(seq); },this); _armatureDisplay.addEventListener(dragonBones.EventObject.START, (event)=>{ cc.log("start"); },this); _armatureDisplay.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, (event)=>{ cc.log("loop complete"); },this); }, this); // var spawn = cc.spawn(cc.moveBy(0.5, 0, 50), cc.scaleTo(0.5, 0.8, 1.4)); var seq = cc.sequence(MoveDown, Finish); this.StarBtn.runAction(seq ); // this.soundNode.getComponent("soundManage").stop(this.soundNode.getComponent("soundManage").Login_ClipID); //this.soundNode.getComponent("soundManage").stop(this.soundNode.getComponent("soundManage").StartGame_ClipID); this.soundNode.getComponent("soundManage").stopAllSoundEffect(); this.unscheduleAllCallbacks(); clearTimeout(this.StartGameTime); }, onStop: function () { utils.toLoadScene("main"); }, });