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 .
WolfNinja2
Party member
Posts: 150 Joined: Wed Oct 24, 2012 10:10 pm
Post
by WolfNinja2 » Fri Jan 17, 2014 11:34 pm
Hey, I'm trying to use love.graphics.draw entirely with table data.
Code: Select all
for k,v in pairs(buttons) do
g.draw(v.pic, v.x, v.y)
end
And here is the table.
Code: Select all
buttons = {
["Start"] = {x = 250, y = 350, width = 100, height = 50, pic = img_btnStart, picClick = img_btnStart_click, click = false, state = 0}
}
It seems so simple but I can't figure it out haha.
veethree
Inner party member
Posts: 877 Joined: Sat Dec 10, 2011 7:18 pm
Post
by veethree » Fri Jan 17, 2014 11:56 pm
Could you post all your code? would make helping you easier.
First, In the loop you call g.draw, Isn't it supposed to be v.draw? 2nd, Is the draw method even defined?
And third, what exactly is the problem, Are you getting an error?
WolfNinja2
Party member
Posts: 150 Joined: Wed Oct 24, 2012 10:10 pm
Post
by WolfNinja2 » Sat Jan 18, 2014 1:41 am
No error, the g.draw is love.graphics.draw, my apologies for not specifying that. And this is the only code other than just love.draw ' ing it that pretains to this code.
Helvecta
Party member
Posts: 167 Joined: Wed Sep 26, 2012 6:35 pm
Post
by Helvecta » Sat Jan 18, 2014 2:55 am
Code: Select all
g = love.graphics
img_btnStart = gfx.newImage("test.png")
buttons = {
["Start"] = {x = 250, y = 350, width = 100, height = 50, pic = img_btnStart, picClick = img_btnStart_click, click = false, state = 0}
}
function love.draw()
for k,v in pairs(buttons) do
g.draw(v.pic, v.x, v.y)
end
end
It seems to work for me; just plop a test.png in the folder you're working with (or check out muh .love!
)
I have a suspicion that you forgot to include the love.draw() function, or put the g.draw call in the wrong place. Drawing stuff is only possible in love.draw!
Attachments
Meow.love
Sometimes I meow (2.2 KiB) Downloaded 253 times
"Bump." -CMFIend420
WolfNinja2
Party member
Posts: 150 Joined: Wed Oct 24, 2012 10:10 pm
Post
by WolfNinja2 » Sat Jan 18, 2014 4:40 am
Whoops crud sorry there is an error.
incorrect parameter type : expected userdata. on the line with g.draw ...
WolfNinja2
Party member
Posts: 150 Joined: Wed Oct 24, 2012 10:10 pm
Post
by WolfNinja2 » Sat Jan 18, 2014 4:40 am
Whoops crud sorry there is an error.
incorrect parameter type : expected userdata. on the line with g.draw ...
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Sat Jan 18, 2014 8:03 am
Listen, OP, please just upload a .love, because now we're kinda fishing in the dark.
WolfNinja2
Party member
Posts: 150 Joined: Wed Oct 24, 2012 10:10 pm
Post
by WolfNinja2 » Sat Jan 18, 2014 4:16 pm
I'm using love 0.8.0. Here is the .love. menu.lua is where the errors are.
Attachments
LOVE Game.love
(448.85 KiB) Downloaded 269 times
veethree
Inner party member
Posts: 877 Joined: Sat Dec 10, 2011 7:18 pm
Post
by veethree » Sat Jan 18, 2014 4:39 pm
You're calling "LOAD_BUTTONS()" where the button picture is defined before you load the image in love.load, So buttons["start"].pic is nil.
jjmafiae
Party member
Posts: 1331 Joined: Tue Jul 24, 2012 8:22 am
Post
by jjmafiae » Sat Jan 18, 2014 5:08 pm
Why not upgrade to 0.9.0?
Users browsing this forum: Amazon [Bot] , Bing [Bot] , Google [Bot] and 6 guests