menu pictures

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
CrocDev
Prole
Posts: 25
Joined: Tue Jun 11, 2013 7:42 pm

menu pictures

Post 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
Attachments
menu game.love
(1.58 KiB) Downloaded 115 times
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: menu pictures

Post 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
CrocDev
Prole
Posts: 25
Joined: Tue Jun 11, 2013 7:42 pm

Re: menu pictures

Post 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
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: menu pictures

Post 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 :)
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: menu pictures

Post by pielago »

Hope this help you :)
add the table as well for multiple!
Attachments
menuImage.love
(7.03 KiB) Downloaded 100 times
CrocDev
Prole
Posts: 25
Joined: Tue Jun 11, 2013 7:42 pm

Re: menu pictures

Post by CrocDev »

thx a lot.but pielago, is there a way too add more buttons. (a newbie!)
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: menu pictures

Post by pielago »

add more buttons to menu??? of course u can but not sure what you want exactly? different buttons or many same buttons???
CrocDev
Prole
Posts: 25
Joined: Tue Jun 11, 2013 7:42 pm

Re: menu pictures

Post by CrocDev »

Diferent buttons

thx
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests