feat(world): add a wrapper for maps new "getBox()" function

This commit is contained in:
Kazhnuz 2019-07-26 11:43:54 +02:00
parent 2da2ffd538
commit 9ea2d2ca40
2 changed files with 13 additions and 4 deletions

View file

@ -289,6 +289,15 @@ function BaseWorld:loadMapObjects()
end end
end end
function BaseWorld:getBox()
if (self.map ~= nil) then
return self.map:getBox()
else
local w, h = core.screen:getDimensions()
return 0, 0, w, h
end
end
function BaseWorld:getDimensions() function BaseWorld:getDimensions()
if (self.map ~= nil) then if (self.map ~= nil) then
return self.map:getDimensions() return self.map:getDimensions()

View file

@ -269,11 +269,11 @@ end
function CameraSystem:limitView(id) function CameraSystem:limitView(id)
local viewx, viewy, vieww, viewh = self:getViewCoordinate(id) local viewx, viewy, vieww, viewh = self:getViewCoordinate(id)
local worldw, worldh = self.world:getDimensions() local worldx, worldy, worldw, worldh = self.world:getBox()
local posx = self.views.list[id].x local posx = self.views.list[id].x
local posy = self.views.list[id].y local posy = self.views.list[id].y
local minx = self.views.width / 2 local minx = worldx + self.views.width / 2
local miny = self.views.height / 2 local miny = worldy + self.views.height / 2
local maxx = worldw - minx local maxx = worldw - minx
local maxy = worldh - miny local maxy = worldh - miny