local x,y=0,149
local run=0
local pi0=20
--ui,图片2,右移动3,左移动4
ui={"7266427303413860920","7266427303413860920_2","7266427303413860920_3","7266427303413860920_4"}
--设置元件位置
local function setpos(p,x,y) Trigger.UI:setPosition(p,ui[1],ui[2],x,y) end
--点击按钮
local function ButtonClick(param)
local p,t=param.eventobjid,param.msgStr
if param.btnelenemt==ui[3] then
if t=="UI.Button.TouchBegin" and run==0 then
run=1
repeat
x=x+pi0
threadpool:wait(0.02)
setpos(p,x,y)
until run==0
run=0 return
elseif t=="UI.Button.Click" then
run=0
x=x+pi0
setpos(p,x,y)
return
end
elseif param.btnelenemt==ui[4] then
if t=="UI.Button.TouchBegin" and run==0 then
run=1
repeat
x=x+pi0
threadpool:wait(0.02)
setpos(p,x,y)
until run==0
run=0 return
elseif t=="UI.Button.Click" then
run=0
x=x-pi0
setpos(p,x,y)
return
end
end
end
ScriptSupportEvent:registerEvent_NoError([=[UI.Button.Click]=], ButtonClick)
ScriptSupportEvent:registerEvent_NoError([=[UI.Button.TouchBegin]=], ButtonClick)
UI图片移动
最新推荐文章于 2024-03-25 13:11:13 发布