permanent variable or: transfer between functions
Posted: Mon Jan 14, 2013 6:39 pm
Hello everybody.
I have a new problem with my function for a selection box, which looks like this:
The problem is, that all entries are only visible, as long as the left mouse button is pressed down.
The code for this action is the following:
The variable "active" is only true, as long as the left mouse button is pressed down.
Is there any possibility to make the action permanent, and not just temporary?
The complete code is the following (The draws are all correct. You can ignore them):
I would be very thankful for any help.
I have a new problem with my function for a selection box, which looks like this:
The problem is, that all entries are only visible, as long as the left mouse button is pressed down.
The code for this action is the following:
Code: Select all
if love.mouse.isDown("l") then
love.audio.play(sound)
y2 = y
active = true
love.timer.sleep(0.1)
end
Is there any possibility to make the action permanent, and not just temporary?
The complete code is the following (The draws are all correct. You can ignore them):
Code: Select all
function GUI_select(selections,x,y)
width = 160
love.graphics.setColor(33,33,33)
love.graphics.rectangle("fill", x, y, width, 32)
love.graphics.setColor(0,0,0)
love.graphics.rectangle("line", x - 1, y - 1, width + 2, 34)
love.graphics.line(x+width - 25, y, x+width - 25, y+33)
x = x-4
if mx > (x+width-25) and mx < (x + width) and my > (y) and my < y + 32 then
love.graphics.setColor(255,255,0)
if love.mouse.isDown("l") then
love.audio.play(sound)
y2 = y
active = true
love.timer.sleep(0.1)
end
else
love.graphics.setColor(255,255,255)
end
love.graphics.triangle("line", x+width - 16, y + 12, x+width, y + 12, x+width - 8, y + 20)
love.graphics.triangle("fill", x+width - 16, y + 12, x+width, y + 12, x+width - 8, y + 20)
love.graphics.setColor(255,255,255)
love.graphics.print("Test!", x + 16, y + (height - 17)/2 - 4)
if active == true then
for selection, s in ipairs(selections) do
y2 = y2 + 32
love.graphics.setColor(33,33,33)
love.graphics.rectangle("fill", x+4, y2, width, 32)
love.graphics.setColor(0,0,0)
love.graphics.line(x+4, y2, x+4+width, y2)
love.graphics.setColor(255,255,255)
love.graphics.print(s, x + 16, y2 + (height - 17)/2 - 4)
end
end
end