-- 将原有弹出UI添加进另一个弹出UI中 function F1() function NewUI:__init(index) -- some other code .... self.panel_list = {} end function NewUI:openRootWnd() -- some other code .... self:changePanel(index) end function NewUI:changePanel(index) if self.cur_panel ~= nil then self.cur_panel:addToParent(false) self.cur_panel = nil end local cur_panel = self.panel_list[index] if cur_panel == nil then if index == key then -- 日常任务 cur_panel = NewView.new() end end self.panel_list[index] = cur_panel if cur_panel ~= nil then self.content:addChild(cur_panel) cur_panel:addToParent(true) self.cur_panel = cur_panel self.cur_index = index end end function NewUI:close_callback() -- some other code ... for k,panel in pairs(self.panel_list) do panel:DeleteMe() end self.panel_list = nil end ---------NewView.lua NewView = class("NewView", function() return ccui.Widget:create() end) -- 将原来的入口(__init)修改为ctor function NewView:ctor() -- some other code ... -- 手动调用 self:open_callback() self:openRootWnd() self:register_event() end function NewView:register_event() if self.new_event == nil then self.new_event = GlobalEvent:getInstance():Bind(Event, function() -- TODO end) end end function NewView:addToParent(status) self:setVisible(status) end function NewView:close_callback() -- some other code ... if self.new_event then GlobalEvent:getInstance():UnBind(self.new_event) self.new_event = nil end end end -- 创建新UI function F2() NewUI = NewUI or BaseClass(BaseView) -- 调用顺序 -- 1 __init -- 2 open_callback -- 3 register_event -- 4 openRootWnd -- 初始化 local controller = NewUIController:getInstance() local model = controller:getModel() function NewUI:__init() self.is_full_screen = true self.win_type = WinType.Full -- self.win_type = WinType.Big -- 显示后面的内容 self.view_tag = ViewMgrTag.DIALOGUE_TAG -- 不显示后面的内容 ---------------- self.view_tag = ViewMgrTag.DIALOGUE_TAG self.win_type = WinType.Mini self.is_full_screen = false self.layout_name = "name/name" -- csb下 路径 self.res_list = { {path = PathTool.getPlistImgForDownLoad("file_name", "name"), type = ResourcesType.plist}, {path = PathTool.getPlistImgForDownLoad("file_name", "name"), type = ResourcesType.single}, } end function NewUI:open_callback() -- self.root_wnd -- self:playEnterAnimatianByObj(self.main_panel, 1) -- 1:左进。2:缩放 end function NewUI:register_event() registerButtonEventListener(self.close_btn, handler(self, self._onClickCloseBtn), true, 2) end function NewUI:openRootWnd() end function NewUI:close_callback() end end --加载图片 function F3() --给Sprite加载图片 self.shop_bg = main_container:getChildByName("bg") if not self.bg_load then local res = PathTool.getTargetRes("bigbg/go_fishing", "shop_bg") self.bg_load = loadSpriteTextureFromCDN(self.shop_bg, res, ResourcesType.single, self.bg_load) --loadImageTextureFromCDN --title_bg:setScale9Enabled(true) --title_bg:setCapInsets(cc.rect(4, 4, 4, 4)) -- 左,右,上,下 end if self.bg_load then self.bg_load:DeleteMe() self.bg_load = nil end --给ImageView加载图片 self.background:loadTexture(self.background_path, LOADTEXT_TYPE) img:ignoreContentAdaptWithSize(true) self.middle_icon:setSpriteFrame(PathTool.getResFrame("guildskill",key)) -- 设置plist中的图片 -- 转主场景 MainuiController:getInstance():changeMainUIStatus(MainuiConst.btn_index.main_scene) createEffectSpine() -- 特效 if self.eff_hero then self.eff_hero:clearTracks() self.eff_hero:removeFromParent() self.eff_hero = nil end end self.icon_panel:setSwallowTouches(false)--滑动布局时可穿透 scroll_view:setScrollBarEnabled(false) -- 隐藏滑动条 award_scroll_view:setTouchEnabled(false) -- 不可滑动 -- 创建英雄模型 function ActionSuperValueWeeklyCardPanel:createHeroModel(parent, bid) if self.hero_spine then doStopAllActions(self.hero_spine) self.hero_spine:removeFromParent() self.hero_spine = nil end self.hero_spine = BaseRole.new(BaseRole.type.partner, bid, nil, {scale = 1}) self.hero_spine:setAnimation(0,PlayerAction.show,true) self.hero_spine:setAnchorPoint(cc.p(0.5,0)) parent:addChild(self.hero_spine) end -------------- -- 设置背景 -- @BattleController:getInstance():getCtrlBattleScene():createHorizontalMap(10019) --------------------------------------------------------------------- -- panel_type -- 前后端对接,要显示的面板。 -- reward_title -- 子活动子项背景 图片 -- bottom_alert -- 可省略 -- title2 -- 可省略 -- top_banner -- 可省略 -- sort_val -- 排序 -- remain_sec -- 子活动剩余活动秒数 -- ico -- 可省略 -- channel_ban -- 可省略 -- cli_type -- 未知作用可省略 -- cli_type_name -- 未知作用可省略 -- time_str -- 可省略 -- bid -- 子活动编号 -- title -- 子活动标题 -- aim_title -- 子活动目标标题(现在用于活动标签面板的背景) 图片 -- camp_id -- 活动编号 -- rule_str -- 可省略 -- type_ico -- 可省略 ---------------------------------------------------------------------