import EventListener from "../../../util/EventListener"; /** * 地图1 剧情1 */ const { ccclass, property } = cc._decorator; @ccclass export default class Step1 extends cc.Component { @property({ displayName: "小矮人", type: cc.Node, }) npc_1: cc.Node = null; onLoad() { EventListener.on("Step1", this.npcJump, this); } onDestroy() { EventListener.off("Step1", this.npcJump, this); } start() { if (this.npc_1) { this.npc_1.active = false; } } npcJump() { if (this.npc_1) { this.npc_1.active = true; cc.tween(this.npc_1).sequence( cc.moveTo(0.5, cc.v2(this.npc_1.x + 300, this.npc_1.y)), cc.callFunc(() => { console.log("======小矮人跳出来======") }) ).start(); } } }