Mouse button released outside an object or the scene


#1

Hi all!
I have a button event where an object is dragged with the mouse/touch. When the button is released it should trigger a condition. That works fine as long as the cursor i still on the object, but if the player moves the cursor (mouse) outside the object or outside the scene and releases the button, nothing happens. Can I either force the cursor to stay on the object or can I trigger the event even if the button is released outside the object?

//Farre


#2

Hi!
Share a screenshot of the related events and we’ll guide you. :slight_smile:


#3

Thanks!
I have an image of a hand on the bottom of the scene. I want the player to drag the hand to the right and left and then release the hand towards a target. To do this I have an object called “hand” that is replaced by another (“open”) hand, that is shot away like a bullet towards the object when the mouse is released (simultaneously the original hand is hidden until the “HandBullet” has reached it’s goal or is outside the scene).

With best regards

Farre


#4

You coupled the condition button released with the touch is on hand, that’s why.
You need to remove the touch is on hand.

What you could do is:
Touch is down + touch is on hand => actions + change variable DraggingHand to 1.
Touch is released + DraggingHand =1 => actions + change variable DraggingHand to 0.


#5

Thanks Gruk,
That worked pretty fine! So there is only one problem left, that might not be solved? If the user releases the mouse/touch outside the scene (if the game is running in a browser window on a computer and not fullscreen on a mobile device), the release action wont be activated by the game. Or am I wrong?

Here is my latest code:

With best regards

Farre


#6

Not sure about that, that might depend on the browser/device used. :confused:


#7

Sorry for late reply, I got into another project for a while. Thanks Gruk!

//Farre