Question from a newbie

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Lvix
Prole
Posts: 6
Joined: Sun Aug 06, 2017 5:53 am

Question from a newbie

Post by Lvix »

Hey, I'm a newbie of LOVE. I just started learning it last night.
I created a directory Chicken which includes two files (main.lua, conf.lua) and an image Chicken.jpg.
However, after I copied some codes from the tutorial and typed a command line in cmd.exe to run the game, an error showed up:

Code: Select all

Error 
main.lua:2: attempt to call field 'newImage' (a nil value)

Traceback 

main.lua:2: in function 'load'
[C]:in function 'xpcall'
in my main.lua, it goes like this

Code: Select all

function love.load() 
	chicken = love.graphics.newImange("Chicken.jpg")
	local	f = love.graphics.newFont(12)
	love.graphics.setFont(f)
	love.graphics.setColor(0,0,0,255)
	love.graphics.setBackgroundColor(255,255,255)
	
end
Does it mean that I could not load Chicken.jpg properly in this way?
where should I place the Chicken.jpg and how to load it?
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Question from a newbie

Post by davisdude »

Your problem is unrelated to chicken.jpg. Look closely at how you spelled "imange" :)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Lvix
Prole
Posts: 6
Joined: Sun Aug 06, 2017 5:53 am

Re: Question from a newbie

Post by Lvix »

davisdude wrote: Sun Aug 06, 2017 7:24 am Your problem is unrelated to chicken.jpg. Look closely at how you spelled "imange" :)
thanks a lot, got it. :o:
Is there an IDE or some useful tools to develop LOVE projects? I found that it is not easy to debug and check the syntax.
And after I loaded it, the image was a black rectangle. It should be a chicken. It seemed that I didn't import it properly.
:|
TIM截图20170806185506.jpg
TIM截图20170806185506.jpg (26.65 KiB) Viewed 5911 times
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Question from a newbie

Post by Sir_Silver »

I believe your chicken is a black rectangle because you called love.graphics.setColor(0, 0, 0, 255) (setting the rendering color to black).
Just get rid of that line and it should look fine.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Question from a newbie

Post by Santos »

Hello! :)

ZeroBrane Studio can debug LOVE projects and has auto-completion for the LOVE API, and documentation if you hover the cursor over a LOVE function.

You can put this line at the top of main.lua so that debugging works:

Code: Select all

if arg[#arg] == "-debug" then require("mobdebug").start() end
And also select Lua Interpreter > LÖVE from the Project menu.

I also recommend checking out the FAQ.
User avatar
Lvix
Prole
Posts: 6
Joined: Sun Aug 06, 2017 5:53 am

Re: Question from a newbie

Post by Lvix »

Sir_Silver wrote: Sun Aug 06, 2017 12:22 pm I believe your chicken is a black rectangle because you called love.graphics.setColor(0, 0, 0, 255) (setting the rendering color to black).
Just get rid of that line and it should look fine.
it works, thanks :awesome:
User avatar
Lvix
Prole
Posts: 6
Joined: Sun Aug 06, 2017 5:53 am

Re: Question from a newbie

Post by Lvix »

Santos wrote: Sun Aug 06, 2017 12:24 pm Hello! :)

ZeroBrane Studio can debug LOVE projects and has auto-completion for the LOVE API, and documentation if you hover the cursor over a LOVE function.

You can put this line at the top of main.lua so that debugging works:

Code: Select all

if arg[#arg] == "-debug" then require("mobdebug").start() end
And also select Lua Interpreter > LÖVE from the Project menu.

I also recommend checking out the FAQ.
Thanks, I'll try it.
Post Reply

Who is online

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