scenes/levels: make sure that the map follow the camera
This commit is contained in:
parent
a3b809f3ba
commit
48283ea40b
|
@ -542,7 +542,7 @@ function Map:setObjectSpriteBatches(layer)
|
|||
|
||||
batches[tileset] = batches[tileset] or newBatch(image)
|
||||
|
||||
local sx = object.width / tile.width
|
||||
local sx = object.width / tile.width
|
||||
local sy = object.height / tile.height
|
||||
|
||||
local batch = batches[tileset]
|
||||
|
|
|
@ -7,7 +7,7 @@ function Level:draw(dt)
|
|||
self:drawBackgroundColor()
|
||||
self.camera:attach()
|
||||
|
||||
self.map:draw()
|
||||
self:drawMap()
|
||||
self:drawCollisions()
|
||||
self:worldDraw()
|
||||
|
||||
|
@ -18,6 +18,16 @@ function Level:draw(dt)
|
|||
self:drawDebugHUD()
|
||||
end
|
||||
|
||||
function Level:drawMap()
|
||||
local tx = self.camera.x - 424 / 2
|
||||
local ty = self.camera.y - 240 / 2
|
||||
|
||||
tx = math.floor(tx)
|
||||
ty = math.floor(ty)
|
||||
|
||||
self.map:draw(-tx, -ty, self.camera.scale, self.camera.scale)
|
||||
end
|
||||
|
||||
function Level:drawBackgroundColor()
|
||||
local r, g, b = self.backcolor
|
||||
love.graphics.setColor(r, g, b)
|
||||
|
|
Loading…
Reference in New Issue