SL:OpenFuncDockTips(data) 这个怎么使用 示例给我
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-05-26 14:22:56 |
👁️ 阅读: 2
SL:OpenFuncDockTips(data) 用于打开功能Dock(功能按钮菜单),通常用在点击玩家或怪物时显示操作菜单。以下是使用示例:
```lua
-- 创建数据
local data = {
type = SL:GetMetaValue("ACTOR_IS_HUMAN", actorID) and DOCKTYPE_NENUM.Func_Monster_Head or DOCKTYPE_NENUM.Func_Player_Head,
targetId = SL:GetMetaValue("ACTOR_ID", actorID),
targetName = SL:GetMetaValue("ACTOR_NAME", actorID),
isHero = SL:GetMetaValue("ACTOR_IS_HERO", actorID),
pos = {x = touchPos.x + 15, y = touchPos.y}
}
-- 打开功能菜单
SL:OpenFuncDockTips(data)
```
**参数说明:**
- `type`:菜单类型,根据目标类型选择(玩家/怪物)
- `targetId`:目标ID
- `targetName`:目标名称
- `isHero`:是否是英雄
- `pos`:菜单显示位置(坐标)
**完整示例:**
```lua
-- 在点击事件中调用
GUI:addOnClickEvent(layout, function(sender)
SL:SetMetaValue("SELECT_TARGET_ID", actorID)
if SL:GetMetaValue("ACTOR_IS_PLAYER", actorID) and not SL:GetMetaValue("WINPLAYMODE") then
local touchPos = GUI:getTouchEndPosition(sender)
local data = {
type = DOCKTYPE_NENUM.Func_Player_Head,
targetId = SL:GetMetaValue("ACTOR_ID", actorID),
targetName = SL:GetMetaValue("ACTOR_NAME", actorID),
isHero = SL:GetMetaValue("ACTOR_IS_HERO", actorID),
pos = {x = touchPos.x + 15, y = touchPos.y}
}
SL:OpenFuncDockTips(data)
end
end)
```
**右键菜单示例:**
```lua
local function downRightBtnFunc(touchPos)
if SL:GetMetaValue("ACTOR_IS_PLAYER", actorID) then
local data = {
type = DOCKTYPE_NENUM.Func_Player_Head,
targetId = SL:GetMetaValue("ACTOR_ID", actorID),
targetName = SL:GetMetaValue("ACTOR_NAME", actorID),
pos = {x = touchPos.x + 15, y = touchPos.y}
}
SL:OpenFuncDockTips(data)
end
end
GUI:addMouseButtonEvent(layout, {
onRightDownFunc = downRightBtnFunc,
needTouchPos = true
})
```
注意:`DOCKTYPE_NENUM` 是枚举类型,需要根据实际配置使用正确的枚举值。
← 返回问答库