0% found this document useful (0 votes)
7 views

ssr.GUI_测试代码--ShowDoc

The document provides a detailed code implementation for creating a GUI using the ssr.GUI framework, including window creation, button functionalities, image displays, list views, and various interactive elements like sliders, checkboxes, and rich text. Each component includes event handling for user interactions, such as clicks and mouse movements, along with visual effects and dynamic content updates. The code demonstrates a comprehensive approach to building a user interface with multiple features and customizable elements.

Uploaded by

马山
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

ssr.GUI_测试代码--ShowDoc

The document provides a detailed code implementation for creating a GUI using the ssr.GUI framework, including window creation, button functionalities, image displays, list views, and various interactive elements like sliders, checkboxes, and rich text. Each component includes event handling for user interactions, such as clicks and mouse movements, along with visual effects and dynamic content updates. The code demonstrates a comprehensive approach to building a user interface with multiple features and customizable elements.

Uploaded by

马山
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

2025/2/4 16:55 ssr.

GUI_测试代码--ShowDoc


ssr.GUI_测试代码

复制

-- wnd
local winWidth = 900
local winHeight = 600
local wnd = ssr.GUI:Win_Create(0, "Win_1", 0, 0, winWidth, winHeight, true)
ssr.GUI:Win_setShow(wnd, 4)
ssr.GUI:Win_setBackGroundColor(wnd, ssr.Color3B.BLACK)
ssr.GUI:Win_setBackGroundOpacity(wnd, 150)
ssr.GUI:Win_SetInESCClose(wnd)
-- ssr.GUI:Win_SetBindNPCIndex( wnd, "10253")
ssr.GUI:Win_SetSwallowRightMouseTouch(wnd, true)

-- 取出窗口大小
local wndSize = ssr.GUI:getContentSize(wnd)

-- 背景图
local image = ssr.GUI:Image_Create(wnd, "Image_bg", wndSize.width/2, wndSize.height/2, "res/public/1900000672.png")
ssr.GUI:addMouseMoveEvent(image, {
onEnterFunc = function()
ssr.print(" !!!!!! OnEnter image")
end,
onLeaveFunc = function()
ssr.print(" !!!!!! OnLeave image")
end,
})

-- 关闭按钮
engine-doc.996m2.com/web/#/22/166 1/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

local button = ssr.GUI:Button_Create(wnd, "Button_1", wndSize.width, wndSize.height, "res/public/1900000510.png")


ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:setAnchorPoint(button, 1, 1)
ssr.GUI:addOnClick(button, function()
ssr.GUI:Win_Close(wnd)
end)

-- listview
local listview = ssr.GUI:ListView_Create(wnd, "ListView_1", 0, 0, 106, wndSize.height, 1)
ssr.GUI:ListView_setBounceEnabled(listview, true)
ssr.GUI:ListView_setItemsMargin(listview, 20)

-- Image 展示
local button = ssr.GUI:Button_Create(listview, "Button_1", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "普通图片")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
-- ssr.GUI:Button_SetGrey(button, true)
ssr.GUI:addOnClick(button, function()
local image = ssr.GUI:Image_Create(wnd, "Image_", wndSize.width/2, wndSize.height/2, "res/public/icon_fubentg_03_1.png")
-- ssr.GUI:Image_SetGrey(image, true)
-- image
ssr.performWithDelay(image, function()
image:removeFromParent()
end, 5)
end)

-- Image 九宫格
local button = ssr.GUI:Button_Create(listview, "Button_2", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "九宫图片")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
engine-doc.996m2.com/web/#/22/166 2/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

local image = ssr.GUI:Image_Create(wnd, "Image_2", wndSize.width/2, wndSize.height/2, "res/public/1900000677.png")


ssr.GUI:Image_setScale9Slice(image, 10, 10, 10, 10)
local index = 1
ssr.schedule(image, function()
index = index + 1
ssr.GUI:setContentSize(image, cc.size(index * 50, index * 50))
end, 1)
ssr.performWithDelay(image, function()
image:removeFromParent()
end, 5)
end)

-- Text
local button = ssr.GUI:Button_Create(listview, "Button_Text", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "文本")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:Text_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 20, ssr.Color3B.RED

ssr.schedule(widget, function()
ssr.GUI:Text_setFontSize(widget, ssr.random(10, 50))
ssr.GUI:Text_setTextColor(widget, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))
end, 0.5)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- layout
local button = ssr.GUI:Button_Create(listview, "Button_layout", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "容器")
engine-doc.996m2.com/web/#/22/166 3/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:Layout_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 100, 100, true)
ssr.GUI:Layout_setBackGroundColorType(widget, 1)

ssr.schedule(widget, function()
ssr.GUI:Layout_setBackGroundColorOpacity(widget, ssr.random(50, 255))
ssr.GUI:Layout_setBackGroundColor(widget, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))
end, 0.5)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- loadingbar
local button = ssr.GUI:Button_Create(listview, "Button_LoadingBar_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "进度条")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:LoadingBar_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/public/b

ssr.schedule(widget, function()
ssr.GUI:LoadingBar_setPercent(widget, ssr.random(0, 100))
ssr.print(ssr.GUI:LoadingBar_getPercent(widget))
end, 0.5)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)
engine-doc.996m2.com/web/#/22/166 4/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

-- TextInput_Create
local button = ssr.GUI:Button_Create(listview, "Button_TextInput_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "输入框")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:TextInput_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 300, 50, 18)
ssr.GUI:TextInput_setString(widget, "我是测试输入内容")

ssr.schedule(widget, function()
ssr.GUI:TextInput_setString(widget, "我是测试输入内容" .. ssr.random(0, 100))
ssr.print(ssr.GUI:TextInput_getString(widget))
end, 0.5)

-- ssr.GUI:TextInput_addOnEvent(widget, function(sender, eventType)


-- if eventType == 0 then
-- ssr.print("输入开始========")
-- elseif eventType == 1 then
-- ssr.print("输入结束========")
-- elseif eventType == 2 then
-- ssr.print("输入改变========")
-- end
-- end)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- TextAtlas_Create
local button = ssr.GUI:Button_Create(listview, "Button_TextAtlas_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "艺术字")
engine-doc.996m2.com/web/#/22/166 5/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:TextAtlas_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "", "res/publi
ssr.GUI:TextAtlas_setString(widget, "321")

ssr.schedule(widget, function()
ssr.GUI:TextAtlas_setString(widget, ssr.random(0, 999999))
ssr.print(ssr.GUI:TextAtlas_getString(widget))
end, 0.5)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- Slider_Create
local button = ssr.GUI:Button_Create(listview, "Button_Slider_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "滑动条")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:Slider_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/public/bg_sz
ssr.GUI:Slider_setPercent(widget, 20)

ssr.GUI:Slider_addOnEvent(widget, function(sender, eventType)


ssr.print("响应类型", eventType)
ssr.print(ssr.GUI:Slider_getPercent(widget))
end)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
engine-doc.996m2.com/web/#/22/166 6/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

end, 5)
end)

-- CheckBox_Create
local button = ssr.GUI:Button_Create(listview, "Button_CheckBox_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "复选框")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:CheckBox_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/public/190

ssr.GUI:CheckBox_addOnEvent(widget, function(sender, eventType)


ssr.print("响应类型", eventType)
ssr.print(ssr.GUI:CheckBox_isSelected(widget))
end)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- ProgressTimer_Create
local button = ssr.GUI:Button_Create(listview, "Button_ProgressTimer_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "圆形进度条")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:ProgressTimer_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/publi
ssr.GUI:ProgressTimer_ProgressFromTo(widget, 2, 0, 100, function()
ssr.print("完成了")
end)

ssr.performWithDelay(widget, function()
engine-doc.996m2.com/web/#/22/166 7/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

widget:removeFromParent()
end, 5)
end)

-- Effect_Create
local button = ssr.GUI:Button_Create(listview, "Button_Effect_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "特效")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local widget = ssr.GUI:Effect_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 0, 1, 0, 0, 0, 1)

ssr.GUI:Effect_addOnCompleteEvent(widget, function()
ssr.print("播完了")
end)

ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 5)
end)

-- RichText_Create
local button = ssr.GUI:Button_Create(listview, "Button_RichText_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "富文本")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local text =
{
"您背包中的<font color='#00cb52'>随机卷/随机石</font>已耗尽",
"您背包中的<font color='#ff0000'>随机卷/随机石</font>已耗尽",
"您背包中的<font color='#00cb52' size='30'>随机卷/随机石</font>已耗尽",
"您背包中的<u><font color='#00cb52'>随机卷/随机石</font></u>已耗尽",
engine-doc.996m2.com/web/#/22/166 8/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

}
local str = text[ssr.random(1, #text)]
local widget = ssr.GUI:RichText_Create(wnd, "widget"..ssr.random(0, 9999)..ssr.random(0, 9999), wndSize.width/2, wndSize.heig
ssr.performWithDelay(widget, function()
widget:removeFromParent()
end, 2)
end)

-- PageView_Create
local button = ssr.GUI:Button_Create(listview, "Button_PageView_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "翻页容器")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local textPage = ssr.GUI:Text_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, 100, 30, ssr.Color3B.ORANGE, "")
ssr.GUI:Text_setString(textPage, "1/3")

local widget = ssr.GUI:PageView_Create(wnd, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 300, 200, 1)


ssr.GUI:setAnchorPoint(widget, cc.p(0.5, 0.5))
ssr.GUI:PageView_setBackGroundColorType(widget, 1)
ssr.GUI:PageView_setBackGroundColorOpacity(widget, ssr.random(50, 255))
ssr.GUI:PageView_setBackGroundColor(widget, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))
ssr.GUI:PageView_addOnEvent(widget, function(sender, eventType)
local itemCount = ssr.GUI:PageView_getItemCount(widget)
local currentIndex = ssr.GUI:PageView_getCurrentPageIndex(widget)
print("eventType", eventType)
ssr.GUI:Text_setString(textPage, (currentIndex+1).. "/" .. itemCount)
end)

local page1 = ssr.GUI:Layout_Create(widget, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 300, 200)


ssr.GUI:Layout_setBackGroundColorType(page1, 1)
ssr.GUI:Layout_setBackGroundColorOpacity(page1, ssr.random(50, 255))
ssr.GUI:Layout_setBackGroundColor(page1, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))
engine-doc.996m2.com/web/#/22/166 9/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

local page2 = ssr.GUI:Layout_Create(widget, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 300, 200)


ssr.GUI:Layout_setBackGroundColorType(page2, 1)
ssr.GUI:Layout_setBackGroundColorOpacity(page2, ssr.random(50, 255))
ssr.GUI:Layout_setBackGroundColor(page2, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))

local page3 = ssr.GUI:Layout_Create(widget, "widget"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 300, 200)


ssr.GUI:Layout_setBackGroundColorType(page3, 1)
ssr.GUI:Layout_setBackGroundColorOpacity(page3, ssr.random(50, 255))
ssr.GUI:Layout_setBackGroundColor(page3, ssr.c3b(ssr.random(0, 255), ssr.random(0, 255), ssr.random(0, 255)))

ssr.performWithDelay(widget, function()
widget:removeFromParent()
textPage:removeFromParent()
end, 10)
end)

-- ItemShow_Create
local button = ssr.GUI:Button_Create(listview, "Button_ItemShow_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "道具图标")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local data = {}
data.index = 10001
data.look = true
data.bgVisible = true
data.count = 10
data.color = 225
data.noMouseTips = true
local item = ssr.GUI:ItemShow_Create(wnd, "ItemShow_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, data)
ssr.GUI:ItemShow_AddReplaceClickEvent(item, function()
ssr.print("替代原有点击触发!")
engine-doc.996m2.com/web/#/22/166 10/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

end)
ssr.GUI:ItemShow_AddPressEvent(item, function()
ssr.print("长按触发!")
end)
ssr.GUI:ItemShow_AddDoubleEvent(item, function()
ssr.print("双击触发!")
end)
ssr.performWithDelay(item, function()
item:removeFromParent()
end, 5)
ssr.GUI:ItemShow_setIconGrey(item, true)
end)

-- ItemBox_Create
local button = ssr.GUI:Button_Create(listview, "Button_ItemBox_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "物品放入框")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local itemBox = ssr.GUI:ItemBox_Create(wnd, "ItemBox_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/public/b
ssr.performWithDelay(itemBox, function()
itemBox:removeFromParent()
end, 5)
end)

-- 跳转
-- local index = ssr.GUI:ListView_GetItemIndex(listview, button)
-- ssr.GUI:ListView_JumpToItem(listview, index)

-- Frames_Create
local button = ssr.GUI:Button_Create(listview, "Button_Frames_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "序列帧")
ssr.GUI:Button_setTitleFontSize(button, 20)
engine-doc.996m2.com/web/#/22/166 11/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local ext = {
count = 10,
speed = 100,
loop = 1,
finishhide = 1
}
local frames = ssr.GUI:Frames_Create(wnd, "Frames_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "public/word_fub
end)

-- TIMETIPS
local button = ssr.GUI:Button_Create(listview, "Button_TIMETIPS_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "倒计时提示")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local function endLinkCB()
ssr.print("-------- time end")
end
local timeTip = ssr.GUI:TIMETIPS_Create(wnd, "TIMETIPS_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 18, {r=255,
ssr.PerformWithDelayGlobal(function()
timeTip:removeFromParent()
end, 5)
end)

-- CircleBar
local button = ssr.GUI:Button_Create(listview, "Button_CircleBar_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "圆形进度条(原标签)")
ssr.GUI:Button_setTitleFontSize(button, 18)
ssr.GUI:Button_setMaxLineWidth(button, 100)
ssr.GUI:Button_titleEnableOutline(button, {r=255,g=0,b=0}, 1)
ssr.GUI:setTouchEnabled(button, true)
engine-doc.996m2.com/web/#/22/166 12/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:addOnClick(button, function()
local circleBar = ssr.GUI:CircleBar_Create(wnd, "CircleBar_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res/pr
ssr.GUI:CircleBar_AddEndLinkCB(circleBar, function()
if circleBar then
circleBar:removeFromParent()
end
end)
end)

-- PercentImg
local button = ssr.GUI:Button_Create(listview, "Button_PercentImg_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "百分比图片")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local percentImg = ssr.GUI:PercentImg_Create(wnd, "PercentImg_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, "res
ssr.performWithDelay(percentImg, function()
percentImg:removeFromParent()
end, 5)
end)

-- UIModel
local button = ssr.GUI:Button_Create(listview, "Button_UIModel_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "人物模型")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local uiModel = ssr.GUI:UIModel_Create(wnd, "PercentImg_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 0, {}, 1)
ssr.performWithDelay(uiModel, function()
uiModel:removeFromParent()
end, 3)
end)

engine-doc.996m2.com/web/#/22/166 13/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

-- EquipShow
local button = ssr.GUI:Button_Create(listview, "Button_EquipShow_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "装备图标")
ssr.GUI:Button_setTitleFontSize(button, 20)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local equipShow = ssr.GUI:EquipShow_Create(wnd, "EquipShow_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 1, tru
ssr.performWithDelay(equipShow, function()
equipShow:removeFromParent()
end, 3)
end)

-- DBItemShow
local button = ssr.GUI:Button_Create(listview, "Button_DBItemShow_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "数据库道具图标")
ssr.GUI:Button_setTitleFontSize(button, 18)
ssr.GUI:Button_setMaxLineWidth(button, 100)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
local dbItemShow = ssr.GUI:DBItemShow_Create(wnd, "DBItemShow_"..ssr.random(0, 9999), wndSize.width/2, wndSize.height/2, 140
ssr.GUI:DBItemShow_setCount( dbItemShow, 18 )
ssr.performWithDelay(dbItemShow, function()
dbItemShow:removeFromParent()
end, 3)
end)

-- QuickCell
local button = ssr.GUI:Button_Create(listview, "Button_QuickCell_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "快捷控件")
ssr.GUI:Button_setTitleFontSize(button, 18)
ssr.GUI:Button_setMaxLineWidth(button, 100)
ssr.GUI:setTouchEnabled(button, true)
engine-doc.996m2.com/web/#/22/166 14/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:addOnClick(button, function()
local listView = ssr.GUI:ListView_Create(wnd, "LISTVIEW", 200, 80, 500, 400, 1)
ssr.GUI:ListView_setBackGroundColor(listView, {r=255,g=255,b=255})
for i = 1, 20 do
ssr.GUI:QuickCell_Create(listView, "QuickCell_Create"..i, 0, 0, 500, 40, function(quickParent)
local item = ssr.GUI:Layout_Create(quickParent, "item", 0, 0, 500, 40)
local itemDesc = ssr.GUI:Text_Create(item, "item_name", 120, 10, 20, {r=200, g=0, b=0}, "name.."..i)
return item
end)
end
end)

-- ScrollView
local button = ssr.GUI:Button_Create(listview, "Button_ScrollView_Create", 0, 0, "res/public/1900000660.png")
ssr.GUI:Button_setTitleText(button, "滚动容器")
ssr.GUI:Button_setTitleFontSize(button, 18)
ssr.GUI:Button_setMaxLineWidth(button, 100)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
if ssr.GUI:getChildByID(wnd, "SCROLLVIEW") then
ssr.GUI:removeChildByID(wnd, "SCROLLVIEW")
end

local scrollView = ssr.GUI:ScrollView_Create(wnd, "SCROLLVIEW", wndSize.width/2, wndSize.height/2, 400, 400, 1)


ssr.GUI:setAnchorPoint(scrollView, 0.5, 0.5)
ssr.GUI:ScrollView_setInnerContainerSize(scrollView, 400, 1000)
ssr.GUI:ScrollView_setBounceEnabled(scrollView, true)
ssr.GUI:ScrollView_setClippingEnabled(scrollView, true)
ssr.GUI:ScrollView_setBackGroundColor(scrollView, {r=200, g=200, b=200})

local text1 = ssr.GUI:Text_Create(scrollView, "Text_1", 200, 200, 18, {r=255, g=255, b=255}, "111111111111111111111111111")
ssr.GUI:setAnchorPoint(text1, 0.5, 0.5)
engine-doc.996m2.com/web/#/22/166 15/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

local text2 = ssr.GUI:Text_Create(scrollView, "Text_2", 200, 700, 18, {r=255, g=0, b=0}, "2222222222222222222222222222")
ssr.GUI:setAnchorPoint(text2, 0.5, 0.5)

end)

-- TableView (复用cell 初始化时只创建可视区域的子cell)


function ssrGlobal_GUITableViewCell_Create( parent, idx, ID )
if ID == "TABLEVIEW" then
local panel = ssr.GUI:Layout_Create(parent, string.format("layout_%s", idx), 0, 0, 600, 40)
local text = ssr.GUI:Text_Create(panel, "TEXT", 0, 20, 18, {r=0,g=255,b=0}, "IDX----------------"..idx)
ssr.GUI:setAnchorPoint(text, 0, 0.5)
end
end

local button = ssr.GUI:Button_Create(listview, "Button_TableView_Create", 0, 0, "res/public/1900000660.png")


ssr.GUI:Button_setTitleText(button, "列表视图(优)")
ssr.GUI:Button_setTitleFontSize(button, 18)
ssr.GUI:Button_setMaxLineWidth(button, 100)
ssr.GUI:setTouchEnabled(button, true)
ssr.GUI:addOnClick(button, function()
if ssr.GUI:getChildByID(wnd, "TABLEVIEW") then
ssr.GUI:removeChildByID(wnd, "TABLEVIEW")
end
local tableView = ssr.GUI:TableView_Create(wnd, "TABLEVIEW", 200, 100, 600, 400, 1, 600, 40, 200)
ssr.GUI:TableView_setBackGroundColor(tableView, {r=255,g=255,b=255})
ssr.GUI:TableView_setDirection(tableView, 2)

local function touchCellFunc(tv, cell)


print(cell)
print(tv)
local idx = ssr.GUI:TableViewCell_getIdx(cell)
local panel = ssr.GUI:getChildByID(cell, string.format("layout_%s", idx))
engine-doc.996m2.com/web/#/22/166 16/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

ssr.GUI:Layout_setBackGroundColor(panel, {r=0, g=200, b=100})


end
-- 添加cell点击事件
ssr.GUI:TableView_addOnTouchedCellEvent( tableView, touchCellFunc )
end)

--[[
-- 新窗口示例!!
local testWin = ssr.GUI:NewWin_Create("TT", 200, 200, 400, 400, false, true, true, false)

local bg = ssr.GUI:Image_Create(testWin, "BG", 200, 200, "res/public/bg_npc_11.jpg")


ssr.GUI:setAnchorPoint(bg, 0.5, 0.5)
ssr.GUI:setContentSize(bg, 400, 400)
ssr.GUI:NewWin_SetDrag(testWin, bg)
ssr.GUI:NewWin_SetTouchZPanel(testWin, bg)
ssr.GUI:NewWin_SetESCClose(testWin, true)

local closeBtn = ssr.GUI:Button_Create(testWin, "CLOSEBTN", 400, 400, "res/public/1900000510.png")


ssr.GUI:setAnchorPoint(closeBtn, 1, 1)
ssr.GUI:addOnClick(closeBtn, function()
-- 关闭窗口方式1
ssr.GUI:NewWin_Close(testWin)
-- 关闭窗口方式2
-- ssr.GUI:NewWin_CloseByID("TT")
end)

local titleText = ssr.GUI:Text_Create(bg, "TITLE", 200, 350, 18, "#00FFFF", "测试界面标题")


ssr.GUI:setAnchorPoint(titleText, 0.5, 0.5)
ssr.GUI:setVisible(titleText, true)

local btn = ssr.GUI:GetWindow(testWin, "CLOSEBTN")


local posX = ssr.GUI:getPositionX(btn)
ssr.GUI:setPositionX(btn, posX + 50)
engine-doc.996m2.com/web/#/22/166 17/18
2025/2/4 16:55 ssr.GUI_测试代码--ShowDoc

local title = ssr.GUI:GetWindow(testWin,"BG/TITLE")


if title then
ssr.GUI:runAction(title, cc.FadeOut:create(0.5))
end

ssr.GUI:NewWin_RegisterGameEvent(testWin, "OnGUINewWinClose", function()


ssr.print("测试界面关闭监听触发!!!!!!!!")
end)

ssr.GUI:NewWin_RegisterGameEvent(testWin, "onPlayerLevelChange", function(data)


ssr.print("角色等级改变!!!!!!!!")
ssr.PrintTable(data)
ssr.print("____________________________________________")
end)
]]

engine-doc.996m2.com/web/#/22/166 18/18

You might also like