function onKillMonsterEffect()
-- 正确获取主玩家
local mainPlayer = global.gamePlayerController:GetMainPlayer()
if not mainPlayer then return end
local originalState = {
walk = mainPlayer:GetWalkSpeed(),
run = mainPlayer:GetRunSpeed(),
attack = mainPlayer:GetAttackSpeed(),
magic = mainPlayer:GetMagicSpeed(),
cameraZ = global.gameMapController:GetViewCamera():getPositionZ()
}
-- 平滑镜头拉近效果
local camera = global.gameMapController:GetViewCamera()
if camera then
local targetZ = originalState.cameraZ * 0.2 -- 目标镜头距离(拉近50%)
local duration = 1.0 -- 拉近过程持续时间(秒)
-- 使用Timeline实现平滑过渡
GUI:Timeline_MoveTo(camera, {x = camera:getPositionX(), y = camera:getPositionY(), z = targetZ}, duration, function()
SL:print("镜头拉近完成")
end)
end
-- 3秒后恢复所有状态
SL:ScheduleOnce(function()
-- 平滑恢复镜头
local camera = global.gameMapController:GetViewCamera()
if camera then
-- 使用引擎的Timeline确保平滑恢复
GUI:Timeline_MoveTo(camera,
{x = camera:getPositionX(), y = camera:getPositionY(), z = originalState.cameraZ},
2.0, -- 恢复时间1秒
function()
SL:print("特效结束,完全恢复到初始状态")
end
)
end
end, 2)
end
onKillMonsterEffect()
-- 事件监听
local function onMonsterDie()
onKillMonsterEffect()
end
SL:RegisterLUAEvent("LUA_EVENT_MONSTER_DIE", "怪物死亡", onMonsterDie)