Question about the first time call love.graphics.print

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
yangshenghan
Prole
Posts: 2
Joined: Sat Jul 12, 2014 6:59 am

Question about the first time call love.graphics.print

Post by yangshenghan »

I wonder know what happened when I use love.graphics.print or love.graphics.printf at the first time.

Why the love.graphics.print altered after the first call? Is there anything needed initialized?

Just curious :-)

Code: Select all

local a = love.graphics.print
lg.print('SOME TEXTS', ...) -- Call love.graphics.print first time
local b = love.graphics.print
lg.print('SOME TEXTS', ...) -- Call love.graphics.print second time
local c = love.graphics.print
print(a == b) -- false
print(a == c) -- false
print(b == c) -- true (Why only the first call change love.graphics.print?)
Last edited by yangshenghan on Sat Jul 12, 2014 5:40 pm, edited 1 time in total.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Question about the first time call love.graphics.print

Post by Plu »

I think that the first call initializes the default font, but I'm not sure.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Question about the first time call love.graphics.print

Post by bartbes »

Indeed, the first time you call print(f) it checks if a font has been loaded, and if not, it loads the default one. As a sidenote, you shouldn't need to tostring the functions to compare them.
yangshenghan
Prole
Posts: 2
Joined: Sat Jul 12, 2014 6:59 am

Re: Question about the first time call love.graphics.print

Post by yangshenghan »

OK. This make sense. But no matter whether I set a font before calling any print function, it changes anyway. So, should I consider this action normal? That is, under any situation, love.graphics.print and love.graphics.printf will change at first call anyway?

By the way, the code is part of my test. I forgot omitting the tostring() function :P
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests