feat(world): add a wrapper for maps new "getBox()" function
This commit is contained in:
parent
2da2ffd538
commit
9ea2d2ca40
2 changed files with 13 additions and 4 deletions
|
@ -289,6 +289,15 @@ function BaseWorld:loadMapObjects()
|
|||
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()
|
||||
if (self.map ~= nil) then
|
||||
return self.map:getDimensions()
|
||||
|
|
|
@ -269,11 +269,11 @@ end
|
|||
|
||||
function CameraSystem:limitView(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 posy = self.views.list[id].y
|
||||
local minx = self.views.width / 2
|
||||
local miny = self.views.height / 2
|
||||
local minx = worldx + self.views.width / 2
|
||||
local miny = worldy + self.views.height / 2
|
||||
local maxx = worldw - minx
|
||||
local maxy = worldh - miny
|
||||
|
||||
|
|
Loading…
Reference in a new issue