Solved: Sprite batch of text window won't render

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
User avatar
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Solved: Sprite batch of text window won't render

Post by Imaculata » Sat Jun 03, 2017 1:13 pm

(Update: this issue has been solved, see bottom of post)

Hi all. It's been a while since I posted, but my game has progressed A LOT (thanks to all the kind help on this forum). I am currently implementing text boxes, so that the player can read signposts and talk to npc's. I'm using a spritebatch for this.

I have a tiny picture of 14 x 7 pixels, containing one tile for the border of the textbox, and one black tile for the inside of the textbox. Each tile is 7x7 pixels. Should be simple, right?

But for some reason the textbox is only rendering partially. I think the code for the textbox is just fine:

Code: Select all

--Update the textbox 
	for x=1,getTextWidth() do
		for y=1, getTextCurrentHeight() do
			if (x>1 and x<getTextWidth() and y>1 and y<getTextCurrentHeight()) then
				--Draw black tile of textbox
				hudBatch:add(hudQuads[2], (x*7)-7, (y*7)-7, 0,1,1)	
				--Draw border tile of textbox
				hudBatch:add(hudQuads[1], (x*7)-7, (y*7)-7, 0,1,1)	
(The above code runs every frame to update the graphics)

I should note that I'm using a function here called getTextWidth(), to retrieve the width of the textbox from another script. The reason I'm using getTextCurrentHeight() instead of getTextHeight(), is because the textbox will be animated. It will fold out from very small, up to it's full height. I have tested and confirmed that these functions do indeed return the correct dimensions of the textbox.


As you can see in the screenshot, only two of the border tiles are drawn, and none of the black tiles appear. The result of this code should be a border of green tiles that is 16 by 2, with a black field on the inside (although the black inside of the text box only becomes visible once the textbox has expanded).

I've also attempted to render the different rows of the textbox individually, by first drawing the two horizontal borders of the textbox, and then the two vertical borders. But even then it seems the rows of sprites interfere with one another, and some refuse to render.

I should note that I'm currently using several spritebatches at the same time (one to render the textbox, and separate spritebatches to render other elements), and rendering them on top of each other, which so far has not been an issue. But lately I've reached a snag where sometimes sprites refuse to render. An earlier attempt to add a bunch of water tiles to the game with a new spritebatch, also resulted in some of the tiles popping in and out for no apparent reason.

Am I using spritebatches incorrectly? Is this issue familiar to anyone?


The issue has been resolved. I was unaware that a sprite batch had a buffersize, and apparently is defaulted to 2. By using the command "hudBatch:setBufferSize(96)" the text window now renders completely.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests