--[[@------------------------------------------------------------------ 说明: 控制人物跳跃移动一个小Tip的操作包 作者: deadline ----------------------------------------------------------------------]] NowOperateJump = NowOperateJump or BaseClass(NowOperate) local NowOperateJump = NowOperateJump function NowOperateJump:__init(start_time, start_pos, end_pos, is_last_tip) self.type = OperateManager.OperateType.Move self.start_pos = start_pos self.end_pos = end_pos self.is_end = false self.move_end_handle = nil self.is_already_do_jump = false --是否已经执行移动操作 end function NowOperateJump:__delete() if self.move_end_handle ~= nil then EventSystem.UnBind(GlobalEventSystem,self.move_end_handle) end if self.change_scene_handle then EventSystem.UnBind(GlobalEventSystem,self.change_scene_handle) end end function NowOperateJump:Init() --先检测能否立即移动再执行该操作 self:DoJumpAction() return true end function NowOperateJump:DoJumpAction( ) self.is_already_do_jump = true --监听主角移动结束 local move_end_callback = function ( tip_count ) self.is_end = true EventSystem.UnBind(GlobalEventSystem,self.move_end_handle) self.move_end_handle = nil end --切换场景的时候,也要结束当前操作包 local change_scene_func = function() self.is_end = true EventSystem.UnBind(GlobalEventSystem,self.change_scene_handle) self.change_scene_handle = nil end -- self.move_end_handle = GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_JUMP_END, move_end_callback) self.change_scene_handle = EventSystem.Bind(GlobalEventSystem,SceneManager.START, change_scene_func) local target_p = co.Vector2(self.end_pos.x*SceneObj.LogicRealRatio.x,self.end_pos.y*SceneObj.LogicRealRatio.y) Scene.Instance:GetMainRole():DoJump(target_p, true) end function NowOperateJump:ExcuteImpl(elaspe_time) --如果还未执行移动操作,则在合适的时间执行该操作 if not self.is_already_do_jump then self:DoJumpAction() end return self.is_end end