GUI:Effect_Create
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-06-15 20:03:35 |
👁️ 阅读: 2
`GUI:Effect_Create` 是创建特效控件的函数。
函数原型:
```lua
local effect = GUI:Effect_Create(parent, "effect_id", x, y, 0, effect_id, 0, 0, 0, 1)
```
参数说明:
- `parent`:父节点对象
- `"effect_id"`:特效控件的唯一标识符(字符串)
- `x, y`:特效的位置坐标
- `0`:z轴层级(通常为0)
- `effect_id`:特效资源ID(数字)
- `0, 0, 0`:旋转、缩放、透明度(通常保持默认0)
- `1`:是否循环播放(1为循环,0为不循环)
使用示例:
```lua
-- 在img_bg上创建一个特效
local s_2 = GUI:Effect_Create(img_bg, "s_2", 86, 354, 0, 32174, 0, 0, 0, 1)
-- 设置特效标签
GUI:setTag(s_2, 0)
-- 播放特效
GUI:Effect_play(effect, 0, 0, false, 1)
-- 停止特效
GUI:Effect_stop(effect, 1)
-- 设置特效可见性
GUI:setVisible(effect, true)
```
常见搭配操作:
1. 创建后设置标签:`GUI:setTag(effect, 0)`
2. 控制播放:`GUI:Effect_play()` / `GUI:Effect_stop()`
3. 设置可见性:`GUI:setVisible(effect, true/false)`
4. 添加播放完成事件:`GUI:Effect_addOnCompleteEvent()`
← 返回问答库