Up to this point I've been using one individual .png for each tile, without issue. For example, if my whole screen should be filled with rows and rows of "brick" tiles, my code would look like
Code: Select all
brickImage = love.graphics.newImage('brick.png')
for y=0,tilesHeight do
for x=0,tilesWidth do
love.graphics.draw(brickImage, x * tilePixelWidth, y * tilePixelHeight)
end
end
Now I'm considering switching to using a SpriteBatch, since Tiled (the program I'm using to make my tile maps) works better with tilesets than individual png images. However, this complicates my love game since now I don't have just a table of images (which is simple) but a SpriteBatch object which then needs a whole table of Quads to pick out tiles. Not only that, but when I create a SpriteBatch, I need to pass in a parameter "maxSprites" which is "The maximum number of sprites that the SpriteBatch can contain at any given time."
* What does that mean? Does that mean the maximum number of times a single sprite can be drawn (i.e., if my batch of sprites only contains one grass tile, which will be drawn 256*256 times to cover the screen, should I put in 1 because it is only holding 1 tile, or 256*256 because it is painting it that many times?)
* Is there any way to just get image objects out of a larger tileset, so I can make my drawing work more similarly to how it did before when everything was an individual .png? I.e., instead of making a spritebatch out of my image and using quads to decide where everything will go, could I just pull out each tile as its own image?
* What happens if I :add() a quad to a SpriteBatch at an x,y location that was already occupied by another tile? If it just replaces the existing one that'd be great, so I could do a sort of "painter's algorithm" style thing by adding each layer lowest to highest to the SpriteBatch, so that the highest layers will always appear above the lowest layers and will never use more than screen_tile_width * screen_tile_height tiles...
Thanks, and sorry for the rambly question. I found the tutorial in the wiki to be extremely obtuse and unhelpful -- took me forever to figure out what it was trying to say, and the example images that weren't even related to the tutorial really threw me off.