Page 1 of 2
mouse_enter signals like godot?
Posted: Fri Sep 07, 2018 7:20 pm
by girng
anything like this, for objects, sprites, etc?
for example, i want to highlight an object with a shader i made (attach it to sprite) on mousehover, and mouse_exit, disable shader
the shader basically makes the sprite have an outline (looks like someone is selecting it)
i can prob convert mozilla's is_overlap 2d function, and then run that in love.update, right? then use width, height, x, and y and then set h = true, h = false, and create my own mouse events? however, what if the object is off screen? don't want it to loop and check it (unneeded)
Re: mouse_enter signals like godot?
Posted: Sat Sep 08, 2018 12:32 pm
by Ulydev
I think you've answered the question yourself.
Here's some pseudo-code that would implement your idea (which is the simplest way to achieve what you want):
Code: Select all
update {
for each object {
if object:is_on_screen() and object:is_overlap(mouse) {
object:mouse_entered()
}
}
}
Re: mouse_enter signals like godot?
Posted: Sat Sep 08, 2018 9:33 pm
by girng
Ulydev wrote: ↑Sat Sep 08, 2018 12:32 pm
I think you've answered the question yourself.
Here's some pseudo-code that would implement your idea (which is the simplest way to achieve what you want):
Code: Select all
update {
for each object {
if object:is_on_screen() and object:is_overlap(mouse) {
object:mouse_entered()
}
}
}
thanks Ulydev.
i am using hump camera right now and it's a lot easier to manage love2d objects, world coordinates, etc.
only problem is lack of UI stuff. i need a UI library similar to Godot's. rich text label, scroll container, vbox, hbox, etc, etc. the latest imgui doesn't work with love2d, and i need to implement a chatbox similar to poe's, which i already did in Godot, but in love2d, it's very hard.
i tried the richtext.lua on github (
https://github.com/gvx/richtext/blob/ma ... chtext.lua)
however, my fps drops decrementally every second when i have this code running. i go from 144fps to 40 or something. and i'm just displaying some text with different colors... never had this issue with godot
see, look i started at 144fps, then starts to decrease every second.
https://i.gyazo.com/f304655bdb85e4be90b ... ff0404.gif
if i remove that richtext, fps stays same.
only reason why i am wanting to convert to love2d because godot has nasty bug with tilemap flickering, while love2d sti is PERFECT. except.. UI stuff is a PITA and gives insane performance degradation
unfortunately am not sure what to do at this point...
Re: mouse_enter signals like godot?
Posted: Sat Sep 08, 2018 9:57 pm
by zorg
Another thread had a gem of a quote, but let me just say it outright; if you can't tell what the issue is with your code in front of you, how do you suppose we help you without seeing it?
I'm assuming either that library's old and buggy, or you're doing something you shouldn't, like calling :new every frame or something; unfortunately i can only guess for now.
Re: mouse_enter signals like godot?
Posted: Sat Sep 08, 2018 10:00 pm
by girng
zorg wrote: ↑Sat Sep 08, 2018 9:57 pm
Another thread had a gem of a quote, but let me just say it outright; if you can't tell what the issue is with your code in front of you, how do you suppose we help you without seeing it?
I'm assuming either that library's old and buggy, or you're doing something you shouldn't, like calling :new every frame or something; unfortunately i can only guess for now.
yes, good point. i'm relativeyly new to lua, just started. but i did get sti to work, player enter map and move around w/ collision
i drew my hp globe with setScissor and bottom ui elements too. i'm transcending slowly.
i will take a look at the code again
might be because of `love.graphics.newCanvas(fbWidth, fbHeight)` me thinks. hmmm that's initializing a new canvas every frame isn't it
i still need to put this text in a scroll container, etc if i even fix this lol fml
Re: mouse_enter signals like godot?
Posted: Sat Sep 08, 2018 10:06 pm
by zorg
Yep, that could be it.
Re: mouse_enter signals like godot?
Posted: Sun Sep 09, 2018 3:49 pm
by Ulydev
girng wrote: ↑Sat Sep 08, 2018 9:33 pmthe latest imgui doesn't work with love2d,
What makes you say this?
Re: mouse_enter signals like godot?
Posted: Mon Sep 10, 2018 9:13 am
by girng
Ulydev wrote: ↑Sun Sep 09, 2018 3:49 pm
girng wrote: ↑Sat Sep 08, 2018 9:33 pmthe latest imgui doesn't work with love2d,
What makes you say this?
https://github.com/slages/love-imgui/issues/27
and that's since may
i'm going back to godot. i gave it try but imo, a proper ui system like godot would be amazing for this love2d project. ty all for the help since i registered. see u around in the game dev communities maybe. ttyl
Re: mouse_enter signals like godot?
Posted: Mon Sep 10, 2018 1:24 pm
by Ulydev
girng wrote: ↑Mon Sep 10, 2018 9:13 am
...
I've been using love-imgui for the past few months and it's been working fine for me. Have you built the binaries on your computer? What's your OS? (NewFrame() takes no arguments)
Re: mouse_enter signals like godot?
Posted: Mon Sep 10, 2018 5:31 pm
by Tjakka5