Can't use functions properly
Posted: Fri Aug 22, 2014 4:13 pm
I am trying to make a basic menu using functions and I sure I am using them wrong, mostly because it does not work. I have no idea how to google this so I need your help!
This is the code:
As you can see, I tried various things in the imprimirButons() function. The first love.graphics.draw() does not work while the second does but I want the first one to work.
Any help will be appreciated!
This is the code:
Code: Select all
function love.load()
carregarButons();
end
function love.draw()
imprimirButons()
end
function love.update()
comprobarRatoliPos();
end
function carregarButons()
butonsImg = {
love.graphics.newImage("/Images/mainMenu/botoJugar/V2/botoJugar.png"), love.graphics.newImage("/Images/mainMenu/botoJugar/V2/botoJugar2.png"), 100, 200 -- buto Jugar
};
estatButoJugarActual = 1;
end
function imprimirButons()
if estatButoJugarActual == 1 then
love.graphics.newImage("Images/mainMenu/botoJugar/V2/botoJugar2.png");
love.graphics.draw( butonsImg[2], 100, 200 );
else
b = love.graphics.newImage("Images/mainMenu/botoJugar/V2/botoJugar.png");
love.graphics.draw( b, 100, 200 );
end
end
function comprobarRatoliPos()
mouseX, mouseY = love.mouse.getPosition();
if mouseX > 100 and mouseX < 350 and mouseY > 200 and mouseY < 270 then
estatButoJugarActual = 2;
else
estatButoJugarActual = 1;
end
end
Any help will be appreciated!