20 lines
524 B
Lua
20 lines
524 B
Lua
--- Добавляет следование за курсором мыши
|
|
--- @class CursorBehavior : Behavior
|
|
local behavior = {}
|
|
behavior.__index = behavior
|
|
behavior.id = "cursor"
|
|
|
|
---@return CursorBehavior
|
|
function behavior.new()
|
|
return setmetatable({}, behavior)
|
|
end
|
|
|
|
function behavior:update()
|
|
self.owner:try(Tree.behaviors.positioned, function(b)
|
|
local mx, my = love.mouse.getX(), love.mouse.getY()
|
|
b.position = Tree.level.camera:toWorldPosition(Vec3 { mx, my })
|
|
end)
|
|
end
|
|
|
|
return behavior
|