blip
blip copied to clipboard
We can interact with UI:Shape will writing code
When you are in the screen to change the code of your game, the click interactions with ui Shapes still works. I haven't tried with other ui types, but I suppose it could work too
Here is the code with which I found that out. when you are in the code section, if you click on the card, it reacts.
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)
Clouds.On = false
Map.Scale = 0.13
Map.Position = {-9, 0, -16.5}
Camera.Position = {0, 15, 0}
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
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