Page 2 of 2

Re: Music Bar;Drawn

Posted: Sat Jun 26, 2010 12:31 pm
by nevon
Robin wrote:
nevon wrote:What's wrong with:

Code: Select all

function love.draw()
    if love.mouse.getX() == 300 and love.mouse.getY() == 320 then
        love.graphics.rectangle(fill,260,260,100,40)
        love.graphics.setColor(255,255,255)
    end
end
?
One pixel is still an awfully small piece of screen. As bartbes pointed out earlier, using an upper and lower bound is better.

Example

Code: Select all

function love.draw()
    local mouseX = love.mouse.getX()
    local mouseY = love.mouse.getY()
    if mouseX > 300 and mouseX < 310 and mouseY > 320 and mouseY < 330 then
        love.graphics.rectangle(fill,260,260,100,40)
        love.graphics.setColor(255,255,255)
    end
end
Something like that.
Well yeah, certainly. I just wondered why you were complicating things by setting the mouse position to two variables in the update function, instead of just doing it all in the draw function.

Re: Music Bar;Drawn

Posted: Sat Jun 26, 2010 2:03 pm
by Jasoco
Fill needs to be a string. "fill". In your Rectangle call.

love.graphics.rectangle("fill", x, y, w, h)

You have it as just fill in your example.

Re: Music Bar;Drawn

Posted: Sat Jun 26, 2010 3:35 pm
by Robin
Oh, and the love.graphics.setColor(255,255,255) probably isn't necessary here either.