FosterRechargeItem = FosterRechargeItem or BaseClass(BaseItem) local FosterRechargeItem = FosterRechargeItem function FosterRechargeItem:__init() self.base_file = "rechargeActivity" self.layout_file = "FosterRechargeItem" -- self.model = 2222222222222222end:getInstance() self:Load() end function FosterRechargeItem:Load_callback() self.nodes = { "con/modelCon", "con/goBtn:obj", "con/bg:raw", "con/effect", "con/title:img", "con" } self:GetChildren(self.nodes) self:AddEvents() SetAnchoredPositionX(self.con, 369) SetAnchoredPositionY(self.con, -3.5) self:UpdateBaseView( ) if self.need_refreshData then self:UpdateView() end end function FosterRechargeItem:AddEvents( ) local on_click = function ( click_obj ) if self.goBtn_obj == click_obj then OpenFun.Open(158, 0) if self.click_cb then self.click_cb() end end end AddClickEvent(self.goBtn_obj, on_click) end function FosterRechargeItem:UpdateBaseView( ) lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetRechargeActivityImage("foster_recharge_bg"), false) self:ClearUIEffect(self.effect) self:AddUIEffect("ui_effect_shouchong01", self.effect, "Top", nil, 0.8, false,nil,nil,nil,nil,nil,nil) end function FosterRechargeItem:UpdateView( ) self:PlayShowAnim() end function FosterRechargeItem:UpdateModel() if self.show_type and KfActivityConst.FosterRechargeData[self.show_type] then local cfg = KfActivityConst.FosterRechargeData[self.show_type] local scale = cfg.scale or 200 local position = cfg.position or Vector3(0,35,-300) local figure_data = cfg.show local res_data = { father_node = self, transform = self.modelCon, fashion_type = tonumber(figure_data[3]), layer_name = self.layer_name, size = Vector2(720,720), scale = scale, figure_id = tonumber(figure_data[4]), ui_model_type = UIModelCommon.ModelType.Model, position = position, } FuncOpenModel:getInstance():SetModelRes(res_data) lua_resM:setOutsideImageSprite(self, self.title_img, GameResPath.GetRechargeActivityImage(cfg.title_res), true) end end function FosterRechargeItem:PlayShowAnim( ) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con) local START_POS = 369 local END_POS = -5 local ANIM_TIME = 0.3 SetAnchoredPositionX(self.con, 369) local function show_func(percent) SetAnchoredPositionX(self.con, START_POS + (END_POS - START_POS) * percent) end local action1 = cc.CustomUpdate.New(ANIM_TIME, show_func) local function callback_1() self:UpdateModel() end local call_func_1 = cc.CallFunc.New(callback_1) local action10 = cc.Sequence.New(action1, call_func_1) cc.ActionManager:getInstance():addAction(action10, self.con) end function FosterRechargeItem:SetData( show_type, click_cb ) self.show_type = show_type self.click_cb = click_cb if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function FosterRechargeItem:__delete( ) self:ClearUIEffect(self.effect) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con) end