local UIChannelChatAnnouncement = UIViewClass() -- 各种Update的handle local updateHandle local totalTime = 5; local gameTime = 0 local timer = 0; local timeout = 0 function UIChannelChatAnnouncement:SetMsg(msg) self.lab_content.text = msg gameTime = totalTime end function UIChannelChatAnnouncement:OnOpened() self:RegistSystemEvent(EventID.UI_ChannelChat_SetMsg, self.SetMsg) --注册Update self:StartRepeatFunc(self.OnUpdateFun, 1) gameTime = totalTime timeout = 0 end function UIChannelChatAnnouncement:OnUpdateFun(deltaTime, timeSinceUpdate) if timeout ~= 1 then gameTime = gameTime - 1; if gameTime < 0 then timeout = 1 UIManager.CloseView(Const_UI_Lua.UIEnum.UIChannelChatAnnouncement) end end end --以下为按钮点击事件 return UIChannelChatAnnouncement