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

#1

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?

0 Likes

#2

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
0 Likes

#3

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?

0 Likes

#4

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

0 Likes

#5

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

#6

It worked perfeclty! Thanks!

2 Likes