Now, for simplicity's sake this is how my SpriteBatch should look like now:
Code: Select all
function love.load()
img_tiles = love.graphics.newImage('tiles.png')
spr_tiles = love.graphics.newSpriteBatch(img_tiles, 2)
local w, h = img_tiles:getDimensions()
tile = {}
tile[1] = love.graphics.newQuad(0, 0, 10, 10, w, h)
tile[2] = love.graphics.newQuad(0, 15, 10, 10, w, h)
updateBatch()
end
function love.update(dt)
updateBatch()
end
function love.draw()
love.graphics.draw(spr_tiles)
end
function updateBatch()
spr_tiles:clear()
-- Too lazy to loop, but took the effort of writing this comment
spr_tiles:add(tile[1], 1, 1)
spr_tiles:add(tile[2], 1, 11)
spr_tiles:flush()
end
I just realized that my first mistake is that I was always running updateBatch() on love.update(dt). Other than that, I have no idea on what to improve upon.
Any suggestionss?