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 » Sat May 14, 2016 6:07 am

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: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: The 'Newfont' function isn't working

Post by Jasoco » Sat May 14, 2016 6:20 am

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 » Sat May 14, 2016 6:33 am

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
Screen Shot 2016-05-13 at 11.29.56 PM.png
Assets folder
Screen Shot 2016-05-13 at 11.29.56 PM.png (25.68 KiB) Viewed 920 times
Screen Shot 2016-05-13 at 11.29.43 PM.png
File Set up
Screen Shot 2016-05-13 at 11.29.43 PM.png (23.05 KiB) Viewed 920 times
Screen Shot 2016-05-13 at 11.29.30 PM.png
Error
Screen Shot 2016-05-13 at 11.29.30 PM.png (35.72 KiB) Viewed 920 times

User avatar
Tjakka5
Party member
Posts: 240
Joined: Thu Dec 26, 2013 12:17 pm

Re: The 'Newfont' function isn't working

Post by Tjakka5 » Sat May 14, 2016 6:59 am

You typed .tff instead of .ttf ^^
Check out my portfolio: http://tjakka5.sorunome.de/

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

Re: The 'Newfont' function isn't working

Post by gravyferry » Sat May 14, 2016 6:26 pm

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

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ulydev and 20 guests