import { EventMgr } from "../Script/Core/Base/EventMgr"; import { Roker_End, Roker_Move } from "./eventDef"; import move from "./move"; const {ccclass, property} = cc._decorator; @ccclass export default class player extends cc.Component { /*===========================自动绑定组件开始===========================*/ /*自动生成*/ @property({type:cc.Node, displayName:""}) private $role_node:cc.Node = null; /*===========================自动绑定组件结束===========================*/ /*===========================自动生成按钮事件开始==========================*/ /*===========================自动生成按钮事件结束==========================*/ moveCpt: move = null; protected onLoad(): void { this.moveCpt = this.node.getComponent(move); if(!this.moveCpt) { this.moveCpt = this.node.addComponent(move); } } protected onEnable(): void { EventMgr.inst.on(Roker_Move, this.onRokerMove, this); EventMgr.inst.on(Roker_End, this.onRokerEnd, this); } protected onDisable(): void { EventMgr.inst.off(Roker_Move, this.onRokerMove, this); EventMgr.inst.off(Roker_End, this.onRokerEnd, this); } onRokerMove(dirction: cc.Vec2){ this.moveCpt.dirction = dirction; } onRokerEnd(){ this.moveCpt.dirction = cc.v2(0,0); } }