blip
blip copied to clipboard
neither object.OnRelease nor PointerUp work when the pointer leave the object
When clicking on an object with an OnRelease function, neither this function nor the PointerUp function work, forcing that, if we want to do the same action when the pointer is on the object and when it leaves it, we have to write twice the same function with onReleaseOutside and onRelease
To try this, I used this code:
Config = {
Map = "zabath.antz_cardfield",
Items = {"zabath.card",
"zabath.kingtermite_card", "zabath.queentermite_queen", "zabath.wingedtermite_card", "zabath.Workertermite_card", "zabath.Soldiertermite_card", "zabath.Deadcicada_card"}
}
hand = 0
cardsPos = {}
cards = {}
cardShape = {}
Client.OnStart = function()
Camera:SetModeFree(Map)
Map.LocalScale = 0.75
Camera.Position = Camera.Position + {75, 15, 135}
Camera.Rotation = {math.pi / 2, math.pi / 2, 0}
Pointer:Show()
UI.Crosshair = false
ease = require("ease")
ui = require("uikit")
ui:init()
Pointer:Hide()
UI.Crosshair = true
Screen.DidResize = function()
ui:fitScreen()
end
bg = ui:createFrame(Color.Black)
upgradeFrame = bg
showUpgradeFrame = true
UI.Crosshair = false
bg:setParent(ui.rootFrame)
Pointer:Show()
drawCard()
end
drawCard = function()
bg = ui:createFrame(Color.None)
bg:setParent(ui.rootFrame)
hand = hand + 1
cardShape[hand] = Shape(Items.zabath.card)
cards[hand] = ui:createShape(cardShape[hand])
cards[hand]:setParent(bg)
cardShape[hand].Scale = 2.5
cardShape[hand].LocalRotation = {math.pi, math.pi / 2, math.pi / 2}
cards[hand].LocalPosition.Y = -200
local width = 1 + ((cards[1].Width * hand / Screen.Width))
for i = 1, hand / 2 do
cards[i].LocalPosition.X = 187.5 - (((hand / 2) - i) * cards[i].Width) / width
end
if hand % 2 == 1 then
cards[hand / 2 + 0.5].LocalPosition.X = 187.5 + cards[hand / 2 + 0.5].Width / (2 * width)
end
for i = hand / 2 + ((hand % 2) / 2) + 1, hand do
cards[i].LocalPosition.X = 187.5 + (((i - (hand / 2 - (hand % 2) / 2)) - 1) * cards[i].Width) / width
if hand % 2 == 1 then
cards[i].LocalPosition.X = cards[i].LocalPosition.X + cards[i].Width / (2 * width)
else
cards[i].LocalPosition.X = cards[i].LocalPosition.X + (cards[i].Width / (2 * width) * 2)
end
end
for i = 1, hand do
cardsPos[i] = cards[i].LocalPosition
end
cards[hand].LocalPosition.Z = cards[hand].LocalPosition.Z - hand * 0.1
for i = 1, hand do
cards[i].onPress = function ()
cardShape[i].Scale = 4
cards[i].LocalPosition.Y = 0
for j = 1, hand do
if i ~= j then
cardShape[j].Scale = 2.5
cards[j].LocalPosition.Y = -200
end
end
end
cards[i].OnPointerDrag = function(pointerEvent)
print("drag", pointerEvent.DX, pointerEvent.DY)
end
cards[i].onRelease = function()
print("released")
end
end
bg.parentDidResize = function()
bg.Width = 500
bg.Height = 250
bg.LocalPosition = Number3((Screen.Width / 2) - (bg.Width / 2), (Screen.Height / 2) - (bg.Height / 2), 0)
end
bg:parentDidResize()
Pointer:Show()
showBg = false
end
Pointer.Down = function()
for i = 1, hand do
cardShape[i].Scale = 2.5
cards[i].LocalPosition.Y = -200
end
end
Pointer.Up = function(pe)
end
Client.Action1 = function(dt)
drawCard()
end
Client.Tick = function(dt)
end