Page 1 of 1

menu pictures

Posted: Thu Jul 24, 2014 1:27 pm
by CrocDev
hello. attached is a menu game that i have made. i would like to know if there is a way of replacing the text for pictures



thx

Re: menu pictures

Posted: Thu Jul 24, 2014 1:59 pm
by rmcode
Yes of course :) You will have to replace the love.graphics.print() with love.graphics.draw(image, ...) in the draw() code of your button:

Code: Select all

local image = love.graphics.newImage("hamster.png");

function button_draw()
	for i,v in ipairs(button) do
		if v.mouseover == false then
			love.graphics.setColor(255,255,255)
		end
		if v.mouseover == true then
			love.graphics.setColor(255,0,0)
		end
		love.graphics.setFont(medium)
		-- love.graphics.print(v.text,v.x,v.y)
               love.graphics.draw(image, v.x, v.y);
	end
end
The wiki page shows an example for loading and drawing an image:
http://love2d.org/wiki/love.graphics.draw

Re: menu pictures

Posted: Sat Jul 26, 2014 10:56 am
by CrocDev
Just a quick question. why do you have to use "local image". plus is there a way to do it so you draw the buttons in main.lua like in my example with text?

also, plzz could you send my a .love file with the changes made.
thx

Re: menu pictures

Posted: Sun Jul 27, 2014 11:33 am
by rmcode
CrocDev wrote:Just a quick question. why do you have to use "local image"
local images is a local variable. You should avoid using global variables whenever you can.
CrocDev wrote:plus is there a way to do it so you draw the buttons in main.lua like in my example with text?
I'm not quite sure what you are asking here :)

Re: menu pictures

Posted: Mon Jul 28, 2014 6:35 am
by pielago
Hope this help you :)
add the table as well for multiple!

Re: menu pictures

Posted: Mon Jul 28, 2014 12:50 pm
by CrocDev
thx a lot.but pielago, is there a way too add more buttons. (a newbie!)

Re: menu pictures

Posted: Mon Jul 28, 2014 6:34 pm
by pielago
add more buttons to menu??? of course u can but not sure what you want exactly? different buttons or many same buttons???

Re: menu pictures

Posted: Fri Aug 01, 2014 4:25 pm
by CrocDev
Diferent buttons

thx