- [NEW] Es pot arrastrar un item per a recolocar-lo en l'habitació

This commit is contained in:
2025-11-15 14:26:08 +01:00
parent 72f4cd04ce
commit b263d989d0
3 changed files with 23 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ editor = {
modified = false,
item_selected=nil,
item_hovered=nil,
item_dragged=nil,
dragged_start_pos=nil,
flip=false,
enable = function()
@@ -74,6 +76,27 @@ editor = {
end
end
else
if editor.item_dragged then
if mouse.down(mouse.LEFT) then
local sprite = sprites.list[editor.item_dragged]
--sprite.pos.x, sprite.pos.y = tx*8, ty*8
sprite.pos = {x=tx*8, y=ty*8}
else
map.surf(rooms.surf_items)
local tile = map.tile(editor.dragged_start_pos.x//8,editor.dragged_start_pos.y//8)
map.tile(editor.dragged_start_pos.x//8,editor.dragged_start_pos.y//8,0)
map.tile(tx,ty,tile)
editor.item_dragged = nil
--local sprite = sprites.list[editor.item_dragged]
--sprite.pos.x,sprite.pos.y = editor.dragged_start_pos.x,editor.dragged_start_pos.y
end
elseif mouse.down(mouse.LEFT) and editor.item_hovered then
editor.item_dragged = editor.item_hovered
--print("item dragged: "..editor.item_dragged.."\n")
local sprite = sprites.list[editor.item_dragged]
editor.dragged_start_pos = {x=sprite.pos.x, y=sprite.pos.y}
editor.modified = true
end
if mouse.press(mouse.LEFT) then
if editor.item_selected then
map.surf(rooms.surf_items)