fix(baseworld): make baseworld not crash when a body is loaded
This commit is contained in:
parent
3314f1e3f9
commit
eafc266544
1 changed files with 42 additions and 26 deletions
|
@ -121,32 +121,6 @@ function BaseWorld:removeActor(actor)
|
|||
end
|
||||
end
|
||||
|
||||
function BaseWorld:moveActor(actor, x, y, filter)
|
||||
-- as the baseworld have no collision function, we return empty collision
|
||||
-- datas, but from the same type than bump2D will return
|
||||
return x, y, {}, 0
|
||||
end
|
||||
|
||||
function BaseWorld:checkCollision(actor, x, y, filter)
|
||||
-- as the baseworld have no collision function, we return empty collision
|
||||
-- datas, but from the same type than bump2D will return
|
||||
return x, y, {}, 0
|
||||
end
|
||||
|
||||
function BaseWorld:queryRect(x, y, w, h)
|
||||
local query = {}
|
||||
local x2, y2 = x + w, y + h
|
||||
for i,v in ipairs(self.actors) do
|
||||
if (v.x >= x) and (v.x + v.w >= x1) and
|
||||
(v.y >= y) and (v.y + v.h >= y1) then
|
||||
|
||||
table.insert(query, v)
|
||||
end
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
||||
|
||||
function BaseWorld:countActors()
|
||||
return #self.actors
|
||||
end
|
||||
|
@ -174,6 +148,48 @@ function BaseWorld:getVisibleActors(id)
|
|||
return returnquery
|
||||
end
|
||||
|
||||
-- BODIES MANAGEMENT FUNCTIONS
|
||||
-- Basic function to handle bodies. Empty function here as baseworld doesn't
|
||||
-- handle bodies
|
||||
|
||||
function BaseWorld:registerBody(body)
|
||||
return nil
|
||||
end
|
||||
|
||||
function BaseWorld:updateBody(body)
|
||||
return x, y, {}, 0
|
||||
end
|
||||
|
||||
function BaseWorld:removeBody(body)
|
||||
return nil
|
||||
end
|
||||
|
||||
function BaseWorld:moveActor(actor, x, y, filter)
|
||||
-- as the baseworld have no collision function, we return empty collision
|
||||
-- datas, but from the same type than bump2D will return
|
||||
return x, y, {}, 0
|
||||
end
|
||||
|
||||
function BaseWorld:checkCollision(actor, x, y, filter)
|
||||
-- as the baseworld have no collision function, we return empty collision
|
||||
-- datas, but from the same type than bump2D will return
|
||||
return x, y, {}, 0
|
||||
end
|
||||
|
||||
function BaseWorld:queryRect(x, y, w, h)
|
||||
local query = {}
|
||||
local x2, y2 = x + w, y + h
|
||||
for i,v in ipairs(self.actors) do
|
||||
if (v.x >= x) and (v.x + v.w >= x1) and
|
||||
(v.y >= y) and (v.y + v.h >= y1) then
|
||||
|
||||
table.insert(query, v)
|
||||
end
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
||||
|
||||
-- INFO FUNCTIONS
|
||||
-- Give infos about the world
|
||||
|
||||
|
|
Loading…
Reference in a new issue