Page 1 of 1

PUSH and URUTORA libraries together

Posted: Tue Jan 26, 2021 4:47 pm
by Vynniel
I want to do a game that's basically GUI. My goal is something like Buriedbornes (a Android, iOS game).
I am currently using two libraries:
* push for resizing: https://github.com/Ulydev/push
* urgent for GUI: https://github.com/tavuntu/urutora

My problem is that as the push changes the location of objects (buttons, texts, panel, everything that is drawn in love.draw ()), the event of triggering a button for example does not happen.
But if I click in the right place (like x = 10), the button is triggered. But, the button is in another place as push changed it's location.

I tried to change the events where X and Y are sent to the urutora, like this (example):

function love.mousepressed (x, y, button)
local rx, ry = push: toGame (x, y)

u: pressed (rx, ry)
end

But no effects.

The example project is attached.

Any advice?

Re: PUSH and URUTORA libraries together

Posted: Wed Jan 27, 2021 8:19 am
by GVovkiv
because push change position where images draws, but not the actual position

you need keep it in mind
so if you want, for example, check button with cursor, than you can do something like this:

Code: Select all

    if xm >= (x * s) + xo and xm <= ((x + w) * s) + xo and ym >= (y * yo) and ym <= ((y + h) * s) + yo then
      return true
where:
xm and ym = cursor coordinates
s = game scale factor
xo and yo = offset of black bars
x and y = where x and y of zone which you want to check starts
w and h = width and height of zone which you want to check

so you can use x, y, width and height of your button
use x and y offset for black bars, so you need fetch it values
also you need fetch scale factor of PUSH

check PUSH documentation, maybe there explained how to get this values

Re: PUSH and URUTORA libraries together

Posted: Wed Jan 27, 2021 12:39 pm
by pgimeno
EDIT: never mind.

Re: PUSH and URUTORA libraries together

Posted: Wed Jan 27, 2021 6:37 pm
by Gunroar:Cannon()
Vynniel wrote: Tue Jan 26, 2021 4:47 pm
function love.mousepressed (x, y, button)
local rx, ry = push: toGame (x, y)

u: pressed (rx, ry)
end
?
I think you have the right idea with push:toGame...check whether (from urutora) inside the lib, by :release(...) whether it calls love.mouse.getX()/getY() or something like that (because in tavuntu's old gooi lib he did that) :P