mouse_enter signals like godot?

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.
girng
Prole
Posts: 39
Joined: Fri Sep 07, 2018 5:42 am

mouse_enter signals like godot?

Post by girng » Fri Sep 07, 2018 7:20 pm

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)

User avatar
Ulydev
Party member
Posts: 439
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: mouse_enter signals like godot?

Post by Ulydev » 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()
    }
  }
}

girng
Prole
Posts: 39
Joined: Fri Sep 07, 2018 5:42 am

Re: mouse_enter signals like godot?

Post by girng » Sat Sep 08, 2018 9:33 pm

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...

User avatar
zorg
Party member
Posts: 2696
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: mouse_enter signals like godot?

Post by zorg » 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? :3

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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

girng
Prole
Posts: 39
Joined: Fri Sep 07, 2018 5:42 am

Re: mouse_enter signals like godot?

Post by girng » Sat Sep 08, 2018 10:00 pm

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? :3

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

User avatar
zorg
Party member
Posts: 2696
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: mouse_enter signals like godot?

Post by zorg » Sat Sep 08, 2018 10:06 pm

Yep, that could be it.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
Ulydev
Party member
Posts: 439
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: mouse_enter signals like godot?

Post by Ulydev » Sun Sep 09, 2018 3:49 pm

girng wrote:
Sat Sep 08, 2018 9:33 pm
the latest imgui doesn't work with love2d,
What makes you say this?

girng
Prole
Posts: 39
Joined: Fri Sep 07, 2018 5:42 am

Re: mouse_enter signals like godot?

Post by girng » Mon Sep 10, 2018 9:13 am

Ulydev wrote:
Sun Sep 09, 2018 3:49 pm
girng wrote:
Sat Sep 08, 2018 9:33 pm
the 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 :P

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 :)

User avatar
Ulydev
Party member
Posts: 439
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: mouse_enter signals like godot?

Post by Ulydev » Mon Sep 10, 2018 1:24 pm

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)

User avatar
Tjakka5
Party member
Posts: 240
Joined: Thu Dec 26, 2013 12:17 pm

Re: mouse_enter signals like godot?

Post by Tjakka5 » Mon Sep 10, 2018 5:31 pm

And builds for 11.1, 64x windows are available here: https://github.com/camchenry/love-imgui ... ter-latest
Check out my portfolio: http://tjakka5.sorunome.de/

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests