SpriteBatches
Posted: Thu May 21, 2015 4:52 pm
I'm not new to game development but not sure if I follow SpriteBatches exactly and want to make sure I understand. I've mostly worked with 3D engines that hide most all details about the gfx card.
I was looking at the following tutorial trying to figure it out. https://love2d.org/wiki/Tutorial:Effici ... _Scrolling
From what I can tell you give a sprite batch an image and tell it the total amount of tiles on it?
Then you create quads which from what I can tell is just data that describes the tiles on the tilesheet.
It seems like we then tell the sprite batch what quads to use and where to draw them, and then in love.draw() we tell the sprite batch to actually do the drawing.
The entire benefit being that when we make a sprite batch the tilesheet image is sent to the gfx card memory and stays there so we aren't sending images there over and over again like "normal" drawing. However, what we do send over and over again is the quad and position information where those quads should go?
I assume each new sprite batch is instantly put in gfx card memory when it's created?
What if my game map needs multiple tilesets to be drawn on screen at once? Like I need 4 tiles from 1 tilesheet and 2 from another? Seems I would need 2 sprite batches (1 for each tileset) and then as I'm looking over my map would I just check what tilesheet/sprite batch it needs and add the quads to that sprite batch and then in love.draw() draw both spritebatches? So if you were to draw only 1 you'd see "holes" in the map but the 2 of them combined makes a full map? How would this handle drawing order requirements of ground layers and foreground layers?
I was looking at the following tutorial trying to figure it out. https://love2d.org/wiki/Tutorial:Effici ... _Scrolling
From what I can tell you give a sprite batch an image and tell it the total amount of tiles on it?
Then you create quads which from what I can tell is just data that describes the tiles on the tilesheet.
It seems like we then tell the sprite batch what quads to use and where to draw them, and then in love.draw() we tell the sprite batch to actually do the drawing.
The entire benefit being that when we make a sprite batch the tilesheet image is sent to the gfx card memory and stays there so we aren't sending images there over and over again like "normal" drawing. However, what we do send over and over again is the quad and position information where those quads should go?
I assume each new sprite batch is instantly put in gfx card memory when it's created?
What if my game map needs multiple tilesets to be drawn on screen at once? Like I need 4 tiles from 1 tilesheet and 2 from another? Seems I would need 2 sprite batches (1 for each tileset) and then as I'm looking over my map would I just check what tilesheet/sprite batch it needs and add the quads to that sprite batch and then in love.draw() draw both spritebatches? So if you were to draw only 1 you'd see "holes" in the map but the 2 of them combined makes a full map? How would this handle drawing order requirements of ground layers and foreground layers?