Problems with the hitboxes!

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
User avatar
Kasperelo
Party member
Posts: 343
Joined: Fri Apr 13, 2012 1:47 pm
Location: The Milky Way

Problems with the hitboxes!

Post 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!
Attachments
followers_0.1.0.love.zip
(12.23 KiB) Downloaded 113 times
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: Problems with the hitboxes!

Post 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
User avatar
Kasperelo
Party member
Posts: 343
Joined: Fri Apr 13, 2012 1:47 pm
Location: The Milky Way

Re: Problems with the hitboxes!

Post by Kasperelo »

I't didn't work? Help please!
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: Problems with the hitboxes!

Post by Adamantos »

... have a look
Attachments
followers_0.1.1.love.zip
(13.14 KiB) Downloaded 101 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests