--正常的呼吸灯动画 ActionBreathLight = ActionBreathLight or BaseClass() local table_insert = table.insert function ActionBreathLight:__init() self._classType = "ActionBreathLight" self.canvas_com = false self.canvas_obj = false self.end_call_back = false self.anim_list = {} end function ActionBreathLight:__delete() self:StopTimer() self.canvas_com = false self.canvas_obj = false self.end_call_back = false self.anim_list = {} end function ActionBreathLight:Init(canvase_root, end_call_back, loop) self.end_call_back = end_call_back self.loop = loop == nil and true or false if canvase_root then self.canvas_com = canvase_root:GetComponent("CanvasGroup") self.canvas_obj = canvase_root.gameObject self:PlayAction() else if self.end_call_back then self.end_call_back() end end end function ActionBreathLight:PlayAction() self.canvas_obj:SetActive(true) self.canvas_com.alpha = 0 local function call_func() local id = TweenLite.to(self, self.canvas_com,TweenLite.UiAnimationType.ALPHA, 1, 1) table_insert(self.anim_list, id) end local callfun1 = cc.CallFunc.New(call_func) ----------- local function call_func2() local id = TweenLite.to(self, self.canvas_com,TweenLite.UiAnimationType.ALPHA, 0, 1) table_insert(self.anim_list, id) end local callfun2 = cc.CallFunc.New(call_func2) local function call_func3() local id = TweenLite.to(self, self.canvas_com,TweenLite.UiAnimationType.ALPHA, 1, 1) table_insert(self.anim_list, id) end local callfun3 = cc.CallFunc.New(call_func3) ---------- local function call_func4() local function end_call_back( ... ) if self.loop then self:StopTimer() self:PlayAction() end if self.call_back then self.call_back() end end local id = TweenLite.to(self, self.canvas_com,TweenLite.UiAnimationType.ALPHA, 0, 1, end_call_back) table_insert(self.anim_list, id) end local callfun4 = cc.CallFunc.New(call_func4) local action = cc.Sequence.New(callfun1, cc.DelayTime.New(2), callfun2, cc.DelayTime.New(1), callfun3, cc.DelayTime.New(2), callfun4, cc.DelayTime.New(1)) cc.ActionManager:getInstance():addAction(action, self.canvas_obj) end function ActionBreathLight:StopAction() self:StopTimer() self.canvas_obj:SetActive(true) self.canvas_com.alpha = 1 end function ActionBreathLight:StopTimer() cc.ActionManager:getInstance():removeAllActionsFromTarget(self.canvas_obj) for i,v in ipairs(self.anim_list) do TweenLite.Stop(v) end self.anim_list = {} end