Page 1 of 1

Problems with the hitboxes!

Posted: Sun Apr 15, 2012 6:37 pm
by Kasperelo
Hi there! I'm trying to make a kind of "avoider" game where you
are getting followed by red dots and stuff, but I'm still stuck at the
hitboxes, 'cause I'm trying to make a menu with a start-button and
a help-button, but the hitboxes doesn't work! Please help me!

Re: Problems with the hitboxes!

Posted: Sun Apr 15, 2012 7:10 pm
by Adamantos
Hey,

when you require "hitboxes", the code inside the file is executed once. You have to put this code inside a function, e.g.

Code: Select all

function checkStartbutton()
  mouseX = love.mouse.getX()
  mouseY = love.mouse.getY()
  if mouseX > hitboxButtonStartLX and mouseX < hitboxButtonStartRX then
    if mouseY > hitboxButtonStartTY and mouseY < hitboxButtonStartBY then
      if love.mouse.isDown "l" then screen = "play"  end
    end
  end

end
Than you have to call this function on every love.update(dt).

Code: Select all

function love.update(dt)
  if screen == "menu" then checkStartbutton() end
  ...
end

Re: Problems with the hitboxes!

Posted: Sun Apr 15, 2012 7:41 pm
by Kasperelo
I't didn't work? Help please!

Re: Problems with the hitboxes!

Posted: Sun Apr 15, 2012 8:03 pm
by Adamantos
... have a look