diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index c0c29a9..2ad0dce 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -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() diff --git a/gamecore/modules/world/camera/init.lua b/gamecore/modules/world/camera/init.lua index e3d292f..7640d02 100644 --- a/gamecore/modules/world/camera/init.lua +++ b/gamecore/modules/world/camera/init.lua @@ -268,12 +268,12 @@ function CameraSystem:getViewScale(id) end function CameraSystem:limitView(id) - local viewx, viewy, vieww, viewh = self:getViewCoordinate(id) - local worldw, worldh = self.world:getDimensions() + local viewx, viewy, vieww, viewh = self:getViewCoordinate(id) + 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