// Learn cc.Class: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html // Learn Attribute: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html var battlenet = require("battlenetmanage") cc.Class({ extends: cc.Component, properties: { newbieblack: { default: null, type: cc.Node, }, newbieHand: { default: null, type: cc.Node, }, newbieLabelNode: { default: null, type: cc.Node, }, newbieLabel: { default: null, type: cc.Label, }, nebiehidearr: { default: [], type: cc.Node, }, newbiehand2Node: { default: null, type: cc.Node, }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start() { this.node.active = false; this.newbieHand.active = false; this.newbieLabelNode.active = false; this.newbieHand.zIndex = 1 this.hsx = 0; this.hsy = 0; this.hdx = 0; this.hdy = 0; cc.bnewbiemgr = this if (battlenet.newbiemode) { for (var i = 0; i < this.nebiehidearr.length; i++) { this.nebiehidearr[i].active = false } } this.newbiehand2Node.active = !this.newbieHand.active }, onDestroy() { cc.bnewbiemgr = null }, stopaction() { var player = cc.clientbattle.player player.dir.x = 0 player.dir.y = 0 player.move_dir.x = player.move_dir.y = 0 player.shot_hold = false cc.gameMgr.player.x = cc.gameMgr.player.pctrl.targetGo.x cc.gameMgr.player.y = cc.gameMgr.player.pctrl.targetGo.y cc.gameMgr.player.pctrl.legstate = 1 cc.gameMgr.player.pctrl.anishoting = false cc.gameMgr.player.pctrl.shootingtime = 0 cc.gameMgr.player.pctrl.spnewbietime = 0.5 cc.Notifier.emit('newbiestart') }, ntouch(tar, path) { cc.battlepause = true this.stopaction() this.node.active = true this.btn = cc.find(path); this.btn.active = true this.tar = tar let pos2 = this.btn.parent.convertToWorldSpaceAR(this.btn); var pos3 = this.node.convertToNodeSpaceAR(pos2); this.btn.oldparent = this.btn.parent this.btn.oldpostion = new cc.v2(this.btn.x, this.btn.y) this.btn.removeFromParent(false) this.node.addChild(this.btn) this.btn.position = pos3 this.newbieHand.setPosition(cc.v2(pos3.x + this.hdx, pos3.y + this.hdy)); this.hdx = this.hdy = 0; this.newbieHand.opacity = 255 this.btn.on(cc.Node.EventType.TOUCH_END, this.btnTouchEnd, this); }, btnTouchEnd() { cc.battlepause = false // this.btn.groupIndex = 0; this.node.active = false this.btn.removeFromParent(false) this.btn.oldparent.addChild(this.btn) this.btn.position = this.btn.oldpostion this.btn.off(cc.Node.EventType.TOUCH_END, this.btnTouchEnd, this); this.btn = null; cc.Notifier.emit('newbieend') this.tar.donext() }, sethandPosAndRotation(data) { this.hdx = data[1]; this.hdy = data[2]; this.newbieHand.rotation = data[3]; }, settipsPosAndRotation(data) { var height = this.newbieLabelNode.height / 2 this.newbieLabelNode.x = data[1]; this.newbieLabelNode.y = data[2]; if (this.newbieLabelNode.y < -this.node.height / 2 + height) { this.newbieLabelNode.y = -this.node.height / 2 + height } }, setText(tar, data) { this.tar = tar if (data[1] == "") { this.newbieLabelNode.active = false; this.node.active = false } else { this.node.active = true this.newbieLabelNode.active = true; if (data[3]) { this.newbieLabelNode.scaleX = 0 this.newbieLabel.string = "" this.newbieLabelNode.runAction(cc.scaleTo(0.2, 1)); } else { this.newbieLabelNode.scale = 1 } // this.newbieLabel.string = data[1]; this.newbieLabel.node.opacity = 255 var self = this var ccb = cc.callFunc(function() { self.newbieLabel.string = data[1]; }); var seq = cc.sequence(cc.fadeOut(0.2), ccb, cc.fadeIn(0.2)) this.newbieLabel.node.runAction(seq); if (data[2] == true) { this.stopaction() setTimeout(() => { // this.newbieblack.on(cc.Node.EventType.TOUCH_END, this.onTouchText, this); }, 500); } } }, onTouchText() { this.node.active = false this.newbieLabelNode.active = false; this.newbieblack.off(cc.Node.EventType.TOUCH_END, this.onTouchText, this); cc.Notifier.emit('newbieend') this.tar.donext() }, showHand() { this.newbieHand.active = true; this.newbieHand.opacity = 0 this.newbiehand2Node.active = !this.newbieHand.active }, hideHand() { this.newbieHand.active = false; this.newbiehand2Node.active = !this.newbieHand.active }, // update (dt) {}, });