Hi,
apologies if this is already known, I skimmed search results for translate and found nothing, so. I'm trying to add resolution support to my game. The backgrounds and gui are all designed for 1024x768, so my current plan is for higher resolutions to just be a bit lazy and add bars around the content, centreing everything in the middle. This seems to work well except.. the first time printf is called it behaves rather oddly. The first character of the string is printed in the correct place, the rest is then printed in the top left corner or completely off screen. All subsequent drawing is reverted back to the original co ordinates before I called translate.
Is this a known problem with a workaround / fix in the works?
Thanks guys.
love.graphics.translate & printf
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: love.graphics.translate & printf
Please upload a .love file so we can test.
Last edited by kikito on Fri Sep 02, 2011 3:19 pm, edited 1 time in total.
When I write def I mean function.
Re: love.graphics.translate & printf
For me, it looks like a bug in you code. So yes, upload your *.love file, then the fix will be in the works.luminosity wrote:Hi,
Is this a known problem with a workaround / fix in the works?
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
Re: love.graphics.translate & printf
I'm not sure how it could be a bug in my code though, you can see the rendering changes midway through a printf, and the "ontinue" from that string has disappeared completely. I didn't upload a .love vecause my game is nearing completion, and I don't want it sitting on a public forum particularly -- not till it's out for sale. However it seems like this isn't a known bug? I'll try reproducing it in a smaller example file.
Thanks,
Thanks,
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: love.graphics.translate & printf
Are you popping your state too early?luminosity wrote:I'm not sure how it could be a bug in my code though, you can see the rendering changes midway through a printf, and the "ontinue" from that string has disappeared completely. I didn't upload a .love vecause my game is nearing completion, and I don't want it sitting on a public forum particularly -- not till it's out for sale. However it seems like this isn't a known bug? I'll try reproducing it in a smaller example file.
Thanks,
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
Re: love.graphics.translate & printf
Okay boiled down to code that is breaking:
which gives me the following screenshot
Code: Select all
function love.draw()
love.graphics.push()
love.graphics.translate(100, 100)
love.graphics.printf("Testing", 100, 100, 1000, "left")
love.graphics.printf("Testing", 100, 120, 1000, "left")
end
Re: love.graphics.translate & printf
Not sure if this is an error in just your demo code, but try to .pop() before the end of your draw.
Re: love.graphics.translate & printf
thelinx is right, you have to keep the push and pops balanced. The example code fills the matrix stack and runs out of space.
This fails silently in LÖVE 0.7.2. The next version will throw a Lua error once the stack is full.
This fails silently in LÖVE 0.7.2. The next version will throw a Lua error once the stack is full.
Shallow indentations.
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
Re: love.graphics.translate & printf
Thanks guys. I swear it used to be balanced in my own game, but I guess I missed something. Will go back and look now.
Should there be a note in the wiki about this? The page for love.graphics.push doesn't explicitly say that pop/pushes must be balanced.
Thanks again.
Should there be a note in the wiki about this? The page for love.graphics.push doesn't explicitly say that pop/pushes must be balanced.
Thanks again.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: love.graphics.translate & printf
I dunno, I went to the wiki to add your suggestion, but it already has this line:luminosity wrote:Thanks guys. I swear it used to be balanced in my own game, but I guess I missed something. Will go back and look now.
Should there be a note in the wiki about this? The page for love.graphics.push doesn't explicitly say that pop/pushes must be balanced.
Thanks again.
I guess we could word that stronger, but it pretty much tells you that you need a call to pop later.love.graphics.push wrote:This function is always used to prepare for a corresponding pop operation later
Kurosuke needs beta testers
Who is online
Users browsing this forum: No registered users and 3 guests