The 'Newfont' function isn't working

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
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

The 'Newfont' function isn't working

Post by gravyferry »

I was attempting to use a font I downloaded and it gives me this error when I attempt to use the newfront function.

The error message
Error
main.lua:17: attempt to call feild 'NewFont' (a nil value)
Traceback
main.lua:17: in function 'load'
[C]: in function 'xpcall'

here's the code involved

Code: Select all

end

function love.draw(dt)
love.graphics.draw(Rectongolusbackground.Img, Rectongolusbackground.x, Rectongolusbackground.y)
love.graphics.print("press 'enter' to start", 640, 360)
end

function love.load(arg)
	Rectongolusbackground.Img = love.graphics.newImage('Assets/Rectbackground.png')
	rng = love.math.newRandomGenerator()
	randomNumber = rng:random(1,100)
	font = love.graphics.NewFont('Assets/Pixelade.tff', 55)
end
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: The 'Newfont' function isn't working

Post by Jasoco »

NewFont isn't capitalized. Proper capitalization is important. It's newFont. All the functions Löve uses are camelCased with the first letter being lowercase. It's one of a few different naming conventions coders use. Like function_name vs. functionName vs. functionname. I prefer camelCase myself. And it just looks weird to capitalize the first character of a function name or variable. But everyone does it different. Since you have a habit of Capitalizing names I can see how you'd make that mistake.

Cheers!
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

Re: The 'Newfont' function isn't working

Post by gravyferry »

Jasoco wrote:NewFont isn't capitalized. Proper capitalization is important. It's newFont. All the functions Löve uses are camelCased with the first letter being lowercase. It's one of a few different naming conventions coders use. Like function_name vs. functionName vs. functionname. I prefer camelCase myself. And it just looks weird to capitalize the first character of a function name or variable. But everyone does it different. Since you have a habit of Capitalizing names I can see how you'd make that mistake.

Cheers!
Thanks for the help I appreciate it.

Unfortunately I am having a new problem, it's saying it can't find the font, I've included pictures of the error, the way I have the files set up for the game, and a picture of the assets folder itself. Code is the same as in the main post, just with it capitalized like 'newFont'.
Attachments
Assets folder
Assets folder
Screen Shot 2016-05-13 at 11.29.56 PM.png (25.68 KiB) Viewed 4195 times
File Set up
File Set up
Screen Shot 2016-05-13 at 11.29.43 PM.png (23.05 KiB) Viewed 4195 times
Error
Error
Screen Shot 2016-05-13 at 11.29.30 PM.png (35.72 KiB) Viewed 4195 times
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: The 'Newfont' function isn't working

Post by Tjakka5 »

You typed .tff instead of .ttf ^^
gravyferry
Prole
Posts: 11
Joined: Sat May 30, 2015 11:15 pm

Re: The 'Newfont' function isn't working

Post by gravyferry »

Tjakka5 wrote:You typed .tff instead of .ttf ^^
omg I feel so dumb, lol, thanks!
Post Reply

Who is online

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