捐献长按逻辑处理

ZhangBiao 2020-10-09 18:59:37 +08:00
parent 533dc2a8fd
commit c55aad07df
1 changed files with 48 additions and 13 deletions

View File

@ -7,6 +7,10 @@ local ActInfo={}
local numList = {}
local btnAddList = {}
local donateList = {}
local triggerList = {}
local isLongPress = false
local isPress = false
local numCount = 0
function this:ctor(mainPanel, gameObject)
this.mainPanel = mainPanel.transform
@ -61,6 +65,9 @@ function this:InitComponent(gameObject)
numList[i] = Util.GetGameObject(this.items,"item"..i.."/text/num"):GetComponent("Text")
btnAddList[i] = Util.GetGameObject(this.items,"item"..i.."/btnAdd")
donateList[i] = Util.GetGameObject(this.items,"item"..i.."/Image")
triggerList[i] = Util.GetEventTriggerListener(donateList[i])
triggerList[i].onPointerDown = triggerList[i].onPointerDown + this.OnPointerDown
triggerList[i].onPointerUp = triggerList[i].onPointerUp + this.OnPointerUp
end
end
@ -112,12 +119,6 @@ function SheJiDaDian:BindEvent()
Util.AddOnceClick(btnAddList[i],function ()
PopupTipPanel.ShowTip("跳转到珍奇宝阁")
end)
Util.AddOnceClick(donateList[i],function ()
PopupTipPanel.ShowTip("捐献")
end)
Util.AddLongPressClick(donateList[i], function()
PopupTipPanel.ShowTip("捐献献献献献献献献献献献献")
end, 0.3)
end
end
@ -125,6 +126,7 @@ end
function this:OnShow(sortingOrder,_parent)
parent = _parent
orginLayer = sortingOrder
FixedUpdateBeat:Add(this.OnUpdate, this)--长按方法注册
this:Refresh()
end
@ -138,6 +140,34 @@ function this:Refresh()
end
function this.OnPointerDown(Pointgo,data)--按下
numCount = 0
isLongPress = true
end
function this.OnPointerUp(Pointgo,data)--抬起
if isPress then
PopupTipPanel.ShowTip("捐献")
end
isLongPress = false
isPress = false
end
--升级处理
function this.OnUpdate()
if isLongPress then
numCount = numCount + 1
if numCount > 20 then
PopupTipPanel.ShowTip("捐献献献献献献献献献献献")
isPress = false
else
if not isPress then
isPress = true
end
end
end
end
function this:LeftUpShow(ActInfo,_curRankType)
local allRankData,myRankData,rankType
if _curRankType then
@ -185,13 +215,13 @@ function this:TimeCountDown(ActInfo)
local giftTime=CalculateSecondsNowTo_N_OClock(5)--领取按钮的倒计时
this.centerTime.text = TimeToFelaxible(giftTime)
this.timer = Timer.New(function()
this.timer1 = Timer.New(function()
this.leftTime.text = Language[10028]..TimeToFelaxible(actTime)
this.centerTime.text = TimeToFelaxible(giftTime)
if actTime < 1 then
this.timer:Stop()
this.timer = nil
this.timer1:Stop()
this.timer1 = nil
parent:ClosePanel()
return
end
@ -201,7 +231,7 @@ function this:TimeCountDown(ActInfo)
actTime = actTime -1
giftTime = giftTime - 1
end, 1, -1, true)
this.timer:Start()
this.timer1:Start()
end
function this:OnSortingOrderChange(_sortingOrder)
@ -209,10 +239,15 @@ function this:OnSortingOrderChange(_sortingOrder)
end
function this:OnHide()
if this.timer then
this.timer:Stop()
this.timer = nil
FixedUpdateBeat:Remove(this.OnUpdate, this)
if this.timer1 then
this.timer1:Stop()
this.timer1 = nil
end
-- if this.timer2 then
-- this.timer2:Stop()
-- this.timer2 = nil
-- end
if this.shopView then
this.shopView = SubUIManager.Close(this.shopView)
this.shopView = nil