local function zhuanpan(msgID, msgData)
local screenWidth = SL:GetMetaValue("SCREEN_WIDTH", 0)
local screenHeight = SL:GetMetaValue("SCREEN_HEIGHT", 0)
local parent = GUI:Win_Create("zhuanpan", 0, 0, 0, 0, false, false, true, false,
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-04-20 15:06:08 |
👁️ 阅读: 7
```lua
local function zhuanpan(msgID, msgData)
local screenWidth = SL:GetMetaValue("SCREEN_WIDTH", 0)
local screenHeight = SL:GetMetaValue("SCREEN_HEIGHT", 0)
local parent = GUI:Win_Create("zhuanpan", 0, 0, 0, 0, false, false, true, false, false, false, 1)
local fullScreenAnim = GUI:Frames_Create(
parent,
"FullScreenFrames",
screenWidth/2,
screenHeight/2,
"res/public/word_fubentg_",
".png",
1,
10,
{speed = 100, count = 10, loop = -1}
)
GUI:setAnchorPoint(fullScreenAnim, 0.5, 0.5)
GUI:setContentSize(fullScreenAnim, screenWidth, screenHeight)
GUI:setIgnoreContentAdaptWithSize(fullScreenAnim, false)
-- GUI:Win_SetMainHide(parent, true)
local layout = GUI:Layout_Create(parent, "layout", screenWidth/2, screenHeight/2, 900, 500)
if layout then
GUI:setAnchorPoint(layout, 0, 00) -- 关键:设置容器锚点为中心
GUI:setTouchEnabled(layout, true)
end
-- 背景图 - 居中显示
local bg_kuang = GUI:Image_Create(layout, "bg_kuang", 450, 250, "res/01/010011.jpg")
if bg_kuang then
GUI:setAnchorPoint(bg_kuang, 0.5, 0.5)
GUI:setContentSize(bg_kuang, {width = 900, height = 500})
end
GUI:LoadExport(layout,"zhuanpan")
local ui = GUI:ui_delegate(layout)
GUI:setCascadeOpacityEnabled(layout, true)
GUI:setOpacity(layout, 0)
GUI:runAction(layout, GUI:ActionFadeIn(2))
GUI:addOnClickEvent(ui.Button_1,function()
GUI:removeFromParent(ui.Button_1)
local cardPositions = {}
local cardSizes = {}
for i = 1, 10 do
local pos = GUI:getPosition(ui['Image_'..i])
local size = GUI:getContentSize(ui['Image_'..i])
cardPositions[i] = {x = pos.x, y = pos.y}
cardSizes[i] = {width = size.width, height = size.height}
GUI:removeFromParent(ui['Image_'..i])
local beimian = GUI:Button_Create(layout, "bei"..i, cardPositions[i].x, cardPositions[i].y, "res/public_win32/1900000610.png")
GUI:setContentSize(beimian, cardSizes[i].width, cardSizes[i].height)
GUI:setVisible(beimian, true)
-- 第5张卡牌不动
if i == 5 then
-- 第5张卡牌不执行移动动画
else
-- 其他卡牌执行移动动画
local function createComplexAnimation()
-- 第一步:移动到中心点
local moveToCenter = GUI:ActionMoveTo(1, -72, -103)
local delay1 = GUI:DelayTime(0.5)
-- 第二步:上下移动
local function createVerticalMove()
local targetY = -103
if i % 2 == 1 then
targetY = -103 + 172
else
targetY = -103 - 172
end
local moveUpDown = GUI:ActionMoveTo(0.5, -72, targetY)
local delay2 = GUI:DelayTime(0.3)
local moveBackVertical = GUI:ActionMoveTo(0.5, -72, -103)
local delay3 = GUI:DelayTime(0.5)
-- 第三步:左右移动
local function createHorizontalMove()
local targetX = -72
if i % 3 == 1 then
targetX = -72 - 142
else
targetX = -72 + 142
end
local moveLeftRight = GUI:ActionMoveTo(0.5, targetX, -103)
local delay4 = GUI:DelayTime(0.3)
local moveBackHorizontal = GUI:ActionMoveTo(0.5, -72, -103)
-- 第四步:旋转一周后回到原位
local function createRotateAndReturn()
local rotateAction = GUI:ActionRotateBy(0.5, 360)
local delay5 = GUI:DelayTime(0.5)
local moveToOriginal = GUI:ActionMoveTo(0.5, cardPositions[i].x, cardPositions[i].y)
return GUI:ActionSequence(
rotateAction,
delay5,
moveToOriginal
)
end
return GUI:ActionSequence(
moveLeftRight,
delay4,
moveBackHorizontal,
GUI:CallFunc(createRotateAndReturn)
)
end
return GUI:ActionSequence(
moveUpDown,
delay2,
moveBackVertical,
delay3,
GUI:CallFunc(createHorizontalMove)
)
end
return GUI:ActionSequence(
moveToCenter,
delay1,
GUI:CallFunc(createVerticalMove)
)
end
GUI:runAction(beimian, createComplexAnimation())
end
end
end)
end
```
这段代码实现了你要求的功能。当点击按钮后,除了第5张卡牌外,其他卡牌会依次执行以下动画:
1. 先移动到中心点(-72, -103)
2. 然后上下移动(奇数牌向上,偶数牌向下)
3. 接着左右移动(i%3==1向左,其他向右)
4. 最后旋转一周后回到各自最初的位置
注意:第5张卡牌会保持不动。每个卡牌的动画是独立执行的,你可以根据需要调整动画时间和移动距离。
← 返回问答库