Help with loading an image on to screen

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
Jamax91x
Prole
Posts: 1
Joined: Wed Mar 04, 2015 4:25 pm

Help with loading an image on to screen

Post by Jamax91x »

Hello, I am currently having an issue with loading a png image on to my programme.

The error message is:

main.lua:65: Incorrect parameter type: expected userdata.

Traceback

[C]: in function 'draw'
main.lua: in function 'draw'
[C]: in function 'xpcall'

Any help with this error would be great :)

I can post the code also, but I have attached the file in question on this post.

Thanks
Attachments
Image I am trying to load in
Image I am trying to load in
StarBarrel.png (61.96 KiB) Viewed 1484 times
main.lua
Main code
(3.16 KiB) Downloaded 74 times
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Help with loading an image on to screen

Post by s-ol »

love.graphics.draw expects an Image as an argument, not a string that is the name of some image. You are passing in "barrel" instead of barrel.s (whose definion you need to uncomment again in line 29).

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Sosolol261
Party member
Posts: 125
Joined: Wed Nov 26, 2014 6:43 am

Re: Help with loading an image on to screen

Post by Sosolol261 »

You forgot to add a image. You would need something like this:

Code: Select all

--under barrel = []
--i stands for image
barrel.i = love.graphics.newImage(theLocationOfTheImage)
theLocationOfTheImage would be something like

Code: Select all

'textures/images/entities/barrel.png'
You got it?
Post Reply

Who is online

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