// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import LocalData, { WorkState } from "../Template/LocalData"; import PopComponet from "../Template/PopComponet"; import GameLevel from "./GameLevel"; const { ccclass, property } = cc._decorator; @ccclass export default class CurrentLevel extends PopComponet { onLoad() { } protected onEnable(): void { let Label = this.node.getChildByName("Sp").getChildByName("Label").getComponent(cc.Label) let Node = this.node.getChildByName("Node") Node.active = false this.weiqi(true) //现在的关卡状态 switch (LocalData.getInstance().getWorkState()) { case WorkState.引导: Label.string = `小鹅巴士` break; case WorkState.上班: if (GameLevel.gameLevel < 5) { Label.string = `第 ${GameLevel.gameLevel} 车` } else { Label.string = `最后一车` this.DifficultyUp_anim() } break; case WorkState.加班: Label.string = `加班车` break; default: cc.error('未知状态'); break; } } protected start(): void { this.scheduleOnce(() => { if (this.isValid) { super.Surpclose() } }, 2) this.bus_anim() } bus_anim() { let Sp = this.node.getChildByName("Sp") Sp.setPosition(-1000, 0) cc.tween(Sp) .to(0.5, { x: 0 }, { easing: 'quadOut' })// quadOut2次方 cubicOut3次方 //quartOut 4次方 .call(() => { this.weiqi(false) }) .delay(1) .to(0.5, { x: 1000 }, { easing: 'quadIn' }) .start() let Mask = this.node.getChildByName("Mask") Mask.opacity = 155 cc.tween(Mask) .to(0.5, { opacity: 220 }) .delay(1) .to(0.5, { opacity: 155 }) .start() } //难度飙升 DifficultyUp_anim() { let Node = this.node.getChildByName("Node") Node.active = true let image = Node.getChildByName("image") cc.tween(image) .to(0.5, { scale: 1.2 }) .to(0.5, { scale: 1 }) .to(0.5, { scale: 1.2 }) .to(0.5, { scale: 1 }) .start() } weiqi(is: boolean) { for (let index = 1; index < 4; index++) { let line3 = this.node.getChildByName("Sp").getChildByName("line" + index) line3.active = is } } }