长传一般慢速移动正常,快速移动会丢失情况
parent
96963a0d18
commit
a65f0fe437
|
|
@ -74,7 +74,7 @@ function M:UpdateHandCard(getcard, mp)
|
|||
|
||||
getcard = getcard or false
|
||||
mp = mp or false
|
||||
|
||||
self.getcard = getcard
|
||||
|
||||
if self._view_handCardList.numItems > 0 then
|
||||
self._view_handCardList:RemoveChildren()
|
||||
|
|
@ -104,8 +104,12 @@ function M:UpdateHandCard(getcard, mp)
|
|||
self._ctr_getCard.selectedIndex = 0
|
||||
end
|
||||
self._view_handCardList.onClickItem:Set(function(context)
|
||||
print("lingemng_view_handCardList")
|
||||
self:__OnClickHandCard(context)
|
||||
end)
|
||||
self._ctr_seletedGet.selectedIndex = 1
|
||||
self._view_handCardList.selectedIndex = -1
|
||||
self._click_index = self._view_handCardList.selectedIndex
|
||||
end
|
||||
|
||||
function M:FillHandCard(i, btn_card, tem_card)
|
||||
|
|
@ -122,48 +126,75 @@ function M:FillHandCard(i, btn_card, tem_card)
|
|||
end
|
||||
|
||||
function M:onTouchBegin(context)
|
||||
-- self.touch = true
|
||||
local button = context.sender
|
||||
self._touchPos = button.xy
|
||||
local card = button.data
|
||||
self._touchIndex = card.index
|
||||
local xy_event = Vector2.New(context.inputEvent.x, context.inputEvent.y)
|
||||
|
||||
card.touch_pos = Vector2.New(button.width / 2, button.height / 2)
|
||||
|
||||
local xy_event = Vector2.New(context.inputEvent.x, context.inputEvent.y)
|
||||
local xy_btnCard = self._view_getCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
if self.__OnDragStart then
|
||||
self:__OnDragStart(button, xy_event)
|
||||
self:__OnDragStart(button, xy_event, xy_btnCard.x >= 0)
|
||||
end
|
||||
end
|
||||
|
||||
function M:onTouchMove(context)
|
||||
local button = context.sender
|
||||
|
||||
-- if self.touch then
|
||||
-- local xy_event = Vector2.New(context.inputEvent.x, context.inputEvent.y)
|
||||
-- local xy_btnCard = self._view_getCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
-- if self.__OnDragStart then
|
||||
-- self:__OnDragStart(button, xy_event, xy_btnCard.x >= 0)
|
||||
-- end
|
||||
-- self.touch = false
|
||||
-- end
|
||||
|
||||
local card = button.data
|
||||
local xy = GRoot.inst:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
button.xy = xy - card.touch_pos
|
||||
end
|
||||
|
||||
function M:__OnDragStart(button, xy_event)
|
||||
function M:__OnDragStart(button, xy_event, isGet)
|
||||
-- self.touchStart = true
|
||||
local card = button.data
|
||||
|
||||
--复制一个按钮
|
||||
local btn_card = self._view_handCardList:GetFromPool("")
|
||||
print("__OnDragStart", btn_card)
|
||||
|
||||
if isGet then
|
||||
local btn_card = self._view_getCard:AddItemFromPool()
|
||||
|
||||
self:FillHandCard(card.index, btn_card, card.card_item)
|
||||
btn_card:GetController('move').selectedIndex = 1
|
||||
self._ctr_seletedGet.selectedIndex = 0
|
||||
self._view_handCardList.selectedIndex = -1
|
||||
else
|
||||
local btn_card = self._view_handCardList:GetFromPool("")
|
||||
|
||||
self:FillHandCard(card.index, btn_card, card.card_item)
|
||||
btn_card:GetController('move').selectedIndex = 1
|
||||
self._view_handCardList:AddChildAt(btn_card, card.index)
|
||||
self._view_handCardList.selectedIndex = card.index
|
||||
self._ctr_seletedGet.selectedIndex = 1
|
||||
end
|
||||
|
||||
|
||||
local xy = GRoot.inst:GlobalToLocal(xy_event)
|
||||
|
||||
--将虚影按钮替换移动的按钮
|
||||
GRoot.inst:AddChild(button)
|
||||
-- GRoot.inst:BringToFront(button)
|
||||
self._view_handCardList:AddChildAt(btn_card, card.index)
|
||||
print("__OnDragStart1", btn_card, card.index)
|
||||
|
||||
self._view_handCardList.selectedIndex = card.index
|
||||
GRoot.inst:AddChild(button)
|
||||
button.xy = xy - card.touch_pos
|
||||
end
|
||||
|
||||
function M:__OnDragEnd(context)
|
||||
-- if not self.touchStart then
|
||||
-- return
|
||||
-- end
|
||||
-- self.touchStart = false
|
||||
local button = context.sender
|
||||
|
||||
local card = button.data
|
||||
|
|
@ -178,74 +209,29 @@ function M:__OnDragEnd(context)
|
|||
if (xy.y < 0 - buttonHeight and _room.curren_outcard_seat == _room.self_player.seat) then
|
||||
self._mainView:OutCard(card.card_item)
|
||||
self.outcard_button = button
|
||||
self._notMove = true
|
||||
else
|
||||
-- xy = self._view_handCardList:GetChildAt(0):GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
-- local xy_btnCard = self._view_getCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
-- if xy.x > 0 then
|
||||
-- print("lingmeng__OnDragEnd1")
|
||||
-- if xy_btnCard.x > 0 then
|
||||
-- coroutine.start(function()
|
||||
-- print("lingmeng__OnDragEnd2")
|
||||
-- local card = card
|
||||
-- local temp_button = temp_button
|
||||
-- local move_button = self._view_getCard:GetChildAt(0)
|
||||
-- local move_button_xy = self._view_handCardList:GlobalToLocal(self._view_getCard:LocalToGlobal(
|
||||
-- Vector2.New(move_button.xy.x, move_button.xy.y)))
|
||||
|
||||
-- local temp_button_xy = self._view_getCard:GlobalToLocal(self._view_handCardList:LocalToGlobal(
|
||||
-- Vector2.New(temp_button.xy.x, temp_button.xy.y)))
|
||||
-- move_button:TweenMove(temp_button_xy, 0.3)
|
||||
-- temp_button:TweenMove(move_button_xy, 0.3)
|
||||
-- coroutine.wait(0.3)
|
||||
-- self._view_handCardList:RemoveChildAt(card.index)
|
||||
-- self._view_getCard:RemoveChildren()
|
||||
-- self._view_getCard:AddChild(temp_button)
|
||||
-- temp_button.xy = Vector2.New(0, 0)
|
||||
-- move_button.data.index = card.index
|
||||
-- self._view_handCardList:AddChildAt(move_button, card.index)
|
||||
-- coroutine.wait(0.1)
|
||||
-- self._notMove = true
|
||||
-- end
|
||||
-- )
|
||||
end
|
||||
-- self:UpdateHandCard(self.getcard)
|
||||
-- if self.getcard then
|
||||
-- self._ctr_seletedGet.selectedIndex = 0
|
||||
-- self._view_handCardList.selectedIndex = -1
|
||||
-- self._click_index = self._view_handCardList.selectedIndex
|
||||
-- else
|
||||
-- local cardIndex = math.floor(xy.x / (buttonWidth + listGrap))
|
||||
-- cardIndex = cardIndex >= self._view_handCardList.numItems and self._view_handCardList.numItems - 1 or
|
||||
-- cardIndex
|
||||
-- if cardIndex ~= card.index then
|
||||
-- coroutine.start(function()
|
||||
-- print("lingmeng__OnDragEnd2")
|
||||
-- local card = card
|
||||
-- local cardIndex = cardIndex
|
||||
-- local temp_button = temp_button
|
||||
-- local move_button = self._view_handCardList:GetChildAt(cardIndex)
|
||||
-- local move_button_xy = move_button.xy
|
||||
-- move_button:TweenMove(temp_button.xy, 0.3)
|
||||
-- temp_button:TweenMove(move_button_xy, 0.3)
|
||||
-- coroutine.wait(0.3)
|
||||
-- self._view_handCardList:RemoveChildAt(card.index)
|
||||
-- cardIndex = cardIndex > card.index and cardIndex - 1 or cardIndex
|
||||
-- self._view_handCardList:RemoveChildAt(cardIndex)
|
||||
-- temp_button.data.index = cardIndex
|
||||
-- self._view_handCardList:AddChildAt(temp_button, cardIndex)
|
||||
-- move_button.data.index = card.index
|
||||
-- self._view_handCardList:AddChildAt(move_button, card.index)
|
||||
-- coroutine.wait(0.1)
|
||||
-- self._notMove = true
|
||||
-- self._ctr_seletedGet.selectedIndex = 1
|
||||
-- self._view_handCardList.selectedIndex = card.index
|
||||
-- self._click_index = self._view_handCardList.selectedIndex
|
||||
-- end
|
||||
-- )
|
||||
-- else
|
||||
-- self._notMove = true
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
temp_button:GetController('move').selectedIndex = 0
|
||||
button:Dispose()
|
||||
end
|
||||
|
||||
function M:outCardMove(context)
|
||||
|
||||
end
|
||||
|
||||
function M:__OnClickHandCard(context)
|
||||
print("lingmeng__OnClickHandCard")
|
||||
self._ctr_seletedGet.selectedIndex = 1
|
||||
self._flag_seletedGet = 0
|
||||
local button = context.data
|
||||
|
|
@ -262,14 +248,14 @@ function M:__OnClickHandCard(context)
|
|||
end
|
||||
|
||||
function M:__OnClickGetCard(context, flag)
|
||||
print("lingmeng__OnClickGetCard")
|
||||
self._view_handCardList.selectedIndex = -1
|
||||
self._click_index = self._view_handCardList.selectedIndex
|
||||
local button = context.sender
|
||||
local _room = DataManager.CurrenRoom
|
||||
if ((Utils.IsDoubleClick(context) or self._flag_seletedGet == 1) and _room.curren_outcard_seat == _room.self_player.seat) then
|
||||
local card = button.data
|
||||
self._mainView:OutCard(card.card_item)
|
||||
self._view_handCardList.selectedIndex = -1
|
||||
self._click_index = self._view_handCardList.selectedIndex
|
||||
self._ctr_seletedGet.selectedIndex = 1
|
||||
self._flag_seletedGet = 0
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue