找回密码
 立即注册
    查看: 7|回复: 0

    点击切换图片函数

    [复制链接]

    326

    主题

    66

    回帖

    1466

    积分

    积分
    1466
    发表于 2025-3-1 00:09:55 | 显示全部楼层 |阅读模式

    1. if win then
    2.   GUI:win_close(win)
    3.   
    4. end
    5. local win = GUI:Win_Create("Win_1", 0, 0, 1136, 640)



    6. local win = GUI:Win_Create("Win_1", 0, 0, 1136, 640)
    7. local imgPaths = {"res/public/1900000610.png", "res/public/1900000601.png", "res/public/1900000602.png"}
    8. local Image_bg = GUI:Image_Create(win, "Image_bg", 0, 0, imgPaths[1])
    9. GUI:setTouchEnabled(Image_bg, true)
    10. GUI:setTag(Image_bg, 1) -- 初始索引为1

    11. GUI:addOnClickEvent(Image_bg, function()
    12.     local index = GUI:getTag(Image_bg)
    13.     index = index % #imgPaths + 1 -- 循环切换
    14.     GUI:Image_loadTexture(Image_bg, imgPaths[index])
    15.     GUI:setTag(Image_bg, index)
    16. end)
    复制代码




    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则