About using SpriteBatch

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
scoobyff666
Prole
Posts: 14
Joined: Fri Sep 16, 2016 5:21 am

About using SpriteBatch

Post by scoobyff666 »

Hi. I'm new to the concept that a SpriteBatch represents. What I could understand hitherto is that I can minimize the number of "draw" operations by using a SpriteBatch to make a lot of copies of the same sprite and then draw all of them with a single draw call.

If I'm right about that, then comes the question: I know I can get a huge speedup when I used a SpriteBatch to draw a map from a tileset that is a texture atlas but, as far as I understand, if instead of that each tile is in a different file, then I need to have a SpriteBatch for each of the files and call a lot of draws, making my program slow. Is this right? And if it is, why? I mean, is it not possible to make something that allows me to reduce the number of draws if I'm using lots of different texture files? And does that mean that if I had a HUGE file with all textures that I need to draw then I would be able to draw everything with a single SpriteBatch and the performance would be optimal?

I wonder if this subject sounds too obvious to you guys, but I still can't get my head around this.
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: About using SpriteBatch

Post by Sulunia »

Not sure if i understood, but you could in a loading screen draw your map to a canvas and then use it as a single giant texture. Probably not a good approach, perhaps someone else can provide a better answer!
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: About using SpriteBatch

Post by s-ol »

scoobyff666 wrote:And does that mean that if I had a HUGE file with all textures that I need to draw then I would be able to draw everything with a single SpriteBatch and the performance would be optimal?
Exactly. Look up 'spritesheet' maybe. This is what 2d games (and websites btw) were made with for a long time btw.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests