fix state thigns and port to love11
This commit is contained in:
parent
ff5abf6bcd
commit
c92c0f6ff7
11 changed files with 130 additions and 96 deletions
13
_helpers.lua
13
_helpers.lua
|
|
@ -58,7 +58,8 @@ function clearRuntimeSaveData(roomName)
|
|||
end
|
||||
|
||||
local function removeTree(path)
|
||||
if love.filesystem.isDirectory(path) then
|
||||
local info = love.filesystem.getInfo(path)
|
||||
if info and info.type == "directory" then
|
||||
for _, child in ipairs(love.filesystem.getDirectoryItems(path)) do
|
||||
removeTree(path .. "/" .. child)
|
||||
end
|
||||
|
|
@ -109,16 +110,18 @@ function cellShapeFromBox(box)
|
|||
return cells
|
||||
end
|
||||
|
||||
-- Which 16x16 cells of a sprite are non-empty, for multi-cell collision shapes.
|
||||
function getCellsFromSprite(sprite)
|
||||
local w, h = sprite:getWidth(), sprite:getHeight()
|
||||
-- Which 16x16 cells of an image are non-empty, for multi-cell collision
|
||||
-- shapes. LÖVE 11 no longer exposes Image:getData(), so inspect ImageData
|
||||
-- directly instead of creating a GPU Image first.
|
||||
function getCellsFromSprite(spritePath)
|
||||
local img = love.image.newImageData(spritePath)
|
||||
local w, h = img:getWidth(), img:getHeight()
|
||||
local box = {w = w / 16, h = h / 16}
|
||||
local boxCells = cellShapeFromBox(box)
|
||||
if box.w < 1 or box.h < 1 then
|
||||
return boxCells
|
||||
end
|
||||
|
||||
local img = sprite:getData()
|
||||
local cellsToRemove = {}
|
||||
|
||||
for _, cell in pairs(boxCells) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue