Page 1 of 1

[solved] How i make UI D:

Posted: Fri May 31, 2013 9:26 pm
by zoboomafoo
Hi, i don't i will have a problem with making a ui itself i just don't get how to attach it to the camera. I'm using the hump library for the cameras, but that's it because i don't really get what the rest of its for. Currently i have "ui" moving with the camera... But when ever the camera moves the text jitters.... Is there a easier way? Is there a way to overlap cameras like have one at like (900000, 900000) looking at the ui and then have one on my player then merge them? Or can you attach things to the window x,y instead of the world x,y? If not how do i stop the text from jiggling around?

Re: How i make UI D:

Posted: Fri May 31, 2013 9:40 pm
by MadByte
simply set the ui outside of the camera drawing range.

i.e

Code: Select all

function love.draw()
  camera:set()
  drawGame()
  camera:unset()
  drawUi()
end
I'm not familiar with the hump camera, but most camera classes work like this.
This solution should work with this one.

Re: How i make UI D:

Posted: Fri May 31, 2013 10:10 pm
by kikito
It's as MadByte says. Most camera systems have an "activation period" during which everything you draw is "drawn as viewed from the camera". In hump's lib that's done with set + unset. Anything you draw after unset will be drawn "as usual" - like when there is no camera. It will also be drawn "on top" if you put it after, or "below" if you put it before.

In my library, gamera, you put the part that is drawn by the camera inside a function.

Code: Select all

function love.draw()
  camera:draw(function())
    drawGame()
  end)
  drawUi()
end
You can see an example with two cameras moving around and a small UI text (the one which says "gamera demo: ... mouse etc etc) on its demo.