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 16:24:30 |
👁️ 阅读: 4
```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)
local layout = GUI:Layout_Create(parent, "layout", screenWidth/2, screenHeight/2, 900, 500)
if layout then
GUI:setAnchorPoint(layout, 0, 0)
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:setOpacity(ui['Image_'..i], 0)
end
local beimianCards = {}
for i = 1, 10 do
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)
beimianCards[i] = beimian
GUI:runAction(beimian, GUI:ActionSequence(
GUI:ActionMoveTo(0.3, -72, -103),
GUI:DelayTime(0.3),
GUI:CallFunc(function()
local targetY = -103
if i % 2 == 1 then
targetY = -103 + 172
else
targetY = -103 - 172
end
GUI:runAction(beimian, GUI:ActionSequence(
GUI:ActionMoveTo(0.3, -72, targetY),
GUI:DelayTime(0.3),
GUI:ActionMoveTo(0.3, -72, -103),
GUI:DelayTime(0.3),
GUI:CallFunc(function()
local targetX = -72
if i % 3 == 1 then
targetX = -72 - 142
else
targetX = -72 + 142
end
GUI:runAction(beimian, GUI:ActionSequence(
GUI:ActionMoveTo(0.3, targetX, -103),
GUI:DelayTime(0.3),
GUI:ActionMoveTo(0.3, -72, -103),
GUI:DelayTime(0.3),
GUI:CallFunc(function()
if i == 10 then
local function moveBackToOriginal(index)
if index > 10 then return end
local card = beimianCards[index]
local originalPos = cardPositions[index]
GUI:setAnchorPoint(card, 0.5, 0.5)
GUI:runAction(card, GUI:ActionSpawn(
GUI:ActionRotateBy(0.4, 360),
GUI:ActionMoveTo(0.4, originalPos.x+60, originalPos.y+100),
GUI:CallFunc(function()
moveBackToOriginal(index + 1)
end)
))
end
moveBackToOriginal(1)
end
end)
))
end)
))
end)
))
GUI:addOnClickEvent(beimian, function()
SL:print('点击了'..i)
-- 隐藏所有背面卡牌
for j = 1, 10 do
GUI:setVisible(beimianCards[j], false)
end
-- 显示所有正面图片
for j = 1, 10 do
GUI:setOpacity(ui['Image_'..j], 255)
end
end)
end
end)
end
```
**修改说明:**
1. 在点击背面卡牌的回调函数中,添加了隐藏所有背面卡牌的代码:
```lua
for j = 1, 10 do
GUI:setVisible(beimianCards[j], false)
end
```
2. 将 `beimianCards` 数组保存下来,这样可以在点击时访问到所有创建的背面卡牌
3. 保持原有的显示正面图片功能不变
这样修改后,当点击任意一张背面卡牌时,会先隐藏所有10张背面卡牌,然后显示所有10张正面图片。
← 返回问答库