Defold-input the mouse over and out at the same time

Hi,

I’m studying Defold and creating a card game like Hearthstone. I’m using the defold-input lib.
I want that when the cursor is over my card (a collection) the card zooms and increase the Y position. It partially works because theres an area within the card that the mouse is over and out at the same time. I think it is because the colision object, but I’m a newbie here and I did not figure out what is happening.

Can you help me?

Here is some of the debug output

DEBUG:SCRIPT: Cursor over hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor out hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor over hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor out hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor over hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor out hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor over hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121
DEBUG:SCRIPT: Cursor out hash: [/collection0/go] hash: [card] 17.499998092651 -215.49998474121

You are probably right that since you’re moving the card on the mouse over it may result in a mouse out as well. Does it work if you mouse over the card from the side or top?

Yes, it works if I move the mouse from the top to the center, this situation occours when the mouse is in the bottom of the card

Ok, got it. A simple solution is to use a collection per card. Each card consists of a root game object with the collision object and then also a child game object with the sprite. When you detect mouse over you move the game object with the sprite only for the visual effect of lifting the card.

1 Like

It worked perfeclty! Thanks!

2 Likes