[solved] How i make UI D:

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
zoboomafoo
Prole
Posts: 7
Joined: Sun May 19, 2013 9:05 pm

[solved] How i make UI D:

Post 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?
Last edited by zoboomafoo on Sat Jun 01, 2013 12:55 am, edited 1 time in total.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: How i make UI D:

Post 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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How i make UI D:

Post 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.
When I write def I mean function.
Post Reply

Who is online

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