From 8b17dabbf118fd10052281a38e95baa0a327a466 Mon Sep 17 00:00:00 2001 From: CloudJ Date: Fri, 2 Jun 2023 20:26:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/main_city/component/main_comp.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 230e284f..0da3cb6a 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -2,6 +2,8 @@ local MainComp = class("MainComp", LuaComponent) local CHAPTER_COMP = "app/ui/main_city/component/chapter_comp" local DAILY_CHALLENGE_COMP = "app/ui/main_city/component/daily_challenge_comp" +local BOTTOM_HEIGHT = 120 + function MainComp:init() self.uiMap = self:getBaseObject():genAllChildren() @@ -39,6 +41,11 @@ function MainComp:refreshModule(selectModule) for idx, cell in pairs(self.moduleMap) do cell:getBaseObject():setActive(self.curModuleType == idx) end + local heroBg = self.uiMap["main_comp.hero_bg"] + local heroBgPosY = heroBg:fastGetAnchoredPositionY() + local sWidth, sHeight = GFunc.getUIExpandScreenSize() + local hSHeight = sHeight / 2 + self.btnPosY = (heroBgPosY + (BOTTOM_HEIGHT / 2 - hSHeight)) / 2 self:refreshBtns() end @@ -60,6 +67,7 @@ function MainComp:refreshFightBtn() end self.uiMap["main_comp.fight_btn"]:addClickListener(moduleCell.onClickFight) + self.uiMap["main_comp.fight_btn"]:setAnchoredPositionY(self.btnPosY) local remainCount = moduleCell:getTodayRemainCount() if remainCount >= 0 then @@ -75,6 +83,7 @@ function MainComp:refreshLeftBtn() self.leftBtn = self.uiMap["main_comp.left_btn"] end self.leftBtn:setActive(false) + self.leftBtn:setAnchoredPositionY(self.btnPosY) local leftIdx = self:getCurLeftModuleIdx() if leftIdx == nil then @@ -104,6 +113,7 @@ function MainComp:refreshRightBtn() self.rightBtn = self.uiMap["main_comp.right_btn"] end self.rightBtn:setActive(false) + self.rightBtn:setAnchoredPositionY(self.btnPosY) local rightIdx = self:getCurRightModuleIdx() if rightIdx == nil then