ExitBtnView = ExitBtnView or BaseClass(BaseView) --[[ 使用范例 local data = { call_back = function() --回调 self.model:Fire(BeachConst.REQ_QUIT_SCENE) end, pos,--自己传位置进来不传就用默认的 } GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP,data) --]] local ExitBtnView = ExitBtnView function ExitBtnView:__init() self.base_file = "common" self.layout_file = "ExitBtnView" self.layer_name = "Main" self.destroy_imm = true self.change_scene_close = false self.append_to_ctl_queue = false --是否要添加进界面堆栈 self.need_show_money = false --是否要显示顶部的金钱栏 -- self.is_set_zdepth = true self.click_bg_toClose = false ------------------------ -- 一级全屏界面: self.hide_maincancas = false --隐藏主界面 self.use_background = false --不一定显示遮罩 self.tween_lite_list = {} ------------------------ self.load_callback = function () self:LoadSuccess() end self.open_callback = function ( ) self:OpenSuccess() end self.close_win_callback = function ( ) self:Close() end self.destroy_callback = function ( ) self:DestroySuccess() end end function ExitBtnView:Open( ) BaseView.Open(self) end function ExitBtnView:LoadSuccess() local nodes = { "leftCon", "leftCon/exitBtn:obj", } self:GetChildren(nodes) self:AddEvent() ------------------------- self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight) self.transform.localPosition = Vector3(0,0,0) self.exitBtn_obj:SetActive(false) self:BindLittleMove(self.leftCon.transform, BaseView.LittleMoveDir.Left, 0) if self.need_fresh then self:ShowExitState(self.data) end end function ExitBtnView:AddEvent() local on_click = function ( click_obj ) if self.exitBtn_obj == click_obj then if self.data and self.data.call_back then self.data.call_back() end end end AddClickEvent(self.exitBtn_obj, on_click) local function onOrientationChange() if self.is_loaded and not self._use_delete_method then SetAnchoredPositionX(self.leftCon.transform, ClientConfig.iphone_x_offset_left) end end self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange) onOrientationChange() local function showExitBtnFunc( data ) self:ShowExitState(data) end self:BindEvent(GlobalEventSystem, EventName.SHOW_EXIT_BTN_STATE, showExitBtnFunc) local function hideExitBtnFunc( ... ) self:HideExitState() end self:BindEvent(GlobalEventSystem, EventName.HIDE_EXIT_BTN_STATE, hideExitBtnFunc) local function hide_dialogue_cur_xy_node()--隐藏当前和对话框重叠位置的节点 self:ShowNode(false) end local function show_dialogue_cur_xy_node()--显示当前和对话框重叠位置的节点 self:ShowNode(true) end self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dialogue_cur_xy_node) self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dialogue_cur_xy_node) end function ExitBtnView:OpenSuccess() self:UpdateView() end function ExitBtnView:UpdateView() if self.is_loaded then else self.need_fresh = true end end --显示 function ExitBtnView:ShowExitState( data ) self.data = data if not self.is_loaded then self.need_fresh = true return end if not self.data then print("huangcong:ExitBtnView [start:112] 没有数据啊,谁传过来的:") return end if not self.is_show then self.is_show = true self:CancelHide() end SetAnchoredPositionX(self.transform,0) self.exitBtn_obj:SetActive(true) local pos = self.data.pos or {x = 200,y = 279} SetAnchoredPosition(self.exitBtn.transform, pos.x, pos.y) end --隐藏 function ExitBtnView:HideExitState( ) if not self.is_loaded then return end self.exitBtn_obj:SetActive(false) self.data = nil end --是否隐藏副本任务栏节点 function ExitBtnView:ShowNode( show ) if not self.is_loaded then return end if self.is_show == show then return end--相同的状态就不再进来做动画了 self.is_show = show for i,v in ipairs(self.tween_lite_list) do if v then TweenLite.Stop(v) v = nil end end if show then local function anim_end_func( ... ) self:CancelHide() end local pos = 0 self.tween_lite_list[1] = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX, pos, 0.2,anim_end_func) else local function anim_end_func( ... ) self:Hide() end local pos = -220 self.tween_lite_list[2] = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSX, pos, 0.2,anim_end_func) end end function ExitBtnView:DestroySuccess( ) for i,v in ipairs(self.tween_lite_list) do if v then TweenLite.Stop(v) v = nil end end end