ability to move spawns in editor
This commit is contained in:
parent
39b65571a0
commit
93bfe0bda4
@ -115,6 +115,7 @@ function stepEditor()
|
||||
|
||||
if Keybind:checkPressed(Keybind.debug.editor) then
|
||||
editor_mode = not editor_mode
|
||||
deselectSpawns()
|
||||
createTileObjects()
|
||||
end
|
||||
end
|
||||
@ -216,8 +217,12 @@ function doEditorEdit()
|
||||
reloadLevelTiles()
|
||||
else
|
||||
if Keybind:checkDown(Keybind.generic.lclick) then
|
||||
deselectSpawns()
|
||||
selectSpawns(mouse_x,mouse_y)
|
||||
end
|
||||
if Keybind:checkDown(Keybind.generic.rclick) then
|
||||
moveSpawns(mouse_x,mouse_y)
|
||||
end
|
||||
end
|
||||
elseif Keybind:checkPressed(Keybind.generic.lshift) then
|
||||
expandLevelCanvas(math.sign(expand_h),math.sign(expand_v))
|
||||
|
@ -10,13 +10,18 @@ end
|
||||
|
||||
function activateSpawns()
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
spawn.archetype:new(unpack(spawn.args))
|
||||
spawn.archetype:new(unpack(spawn.args))
|
||||
end
|
||||
end
|
||||
|
||||
function deselectSpawns()
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
spawn.selected = nil
|
||||
end
|
||||
end
|
||||
|
||||
function selectSpawns(x,y)
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
spawn.selected = nil
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
local left = spawn.args[1] - Camera.pos.x - offset_x
|
||||
local top = spawn.args[2] - Camera.pos.y - offset_y
|
||||
@ -40,6 +45,15 @@ function selectSpawns(x,y)
|
||||
end
|
||||
end
|
||||
|
||||
function moveSpawns(x,y)
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
if spawn.selected then
|
||||
spawn.args[1] = math.floor(x/game.scale)+Camera.pos.x
|
||||
spawn.args[2] = math.floor(y/game.scale)+Camera.pos.y
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawSpawns()
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
@ -64,19 +78,15 @@ function drawSpawns()
|
||||
)
|
||||
|
||||
if spawn.selected then
|
||||
local text = ""
|
||||
for i=1, #spawn.args do
|
||||
text = text .. tostring(spawn.args[i])..", "
|
||||
local text = spawn.archetype.type.."\n["..spawn.args[1]..","..spawn.args[2].."]\n"
|
||||
for i=3, #spawn.args do
|
||||
if i > 3 then text = text .. ", " end
|
||||
text = text .. tostring(spawn.args[i])
|
||||
end
|
||||
love.graphics.print(
|
||||
spawn.archetype.type,
|
||||
spawn.args[1] - Camera.pos.x + 20,
|
||||
spawn.args[2] - Camera.pos.y
|
||||
)
|
||||
love.graphics.print(
|
||||
text,
|
||||
spawn.args[1] - Camera.pos.x + 20,
|
||||
spawn.args[2] - Camera.pos.y + 20
|
||||
spawn.args[2] - Camera.pos.y
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user