Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » If Touching Mouse Pointer Solution.
- jonasreimers123
-
4 posts
If Touching Mouse Pointer Solution.
So i have set it if the mouse pointer is touching a object it is sending a broadcast
and in another sprite that is a custom made speech bubble if it gets the broadcast it is going to show up above the other sprite. Now. I want to do if i click the first sprite that it sends a broadcast to the speech bubble and if it gets the broadcast it going to change the costume and is going to show. But now its just showing for a small second.
First sprite:
speech bubble sprite:
I hope you understand what i am trying to say

First sprite:
speech bubble sprite:
I hope you understand what i am trying to say

Last edited by jonasreimers123 (May 7, 2022 14:22:51)
- rgantzos
-
100+ posts
If Touching Mouse Pointer Solution.
This code looks absolutely fine… I'm not sure what the error is. Maybe it's in a different part of the code, one that causes the first sprite to hide..? When the sprite that the mouse pointer is touching is hidden, then it no longer is able to “touch” the mouse pointer. An alternative to hiding that works is to set ghost effect to 100. Then, you can't see it, but *technically* it's still there.
- dave3m
-
500+ posts
If Touching Mouse Pointer Solution.
I'm guessing that your event "touched end“ is probably hiding the speech bubble sprite?
Your script should make the speech bubble appear while hovering over the first sprite,
but your forever loop is going to be sending a very large number of messages because it will run continuously spamming the event ”touched end" once the mouse pointer is no longer touching that first sprite.
Instead of broadcasting the second event in the else condition of if touching mouse-pointer?, you would probably rather have it wait until it was no longer touching the pointer and then send the message once.
The broadcast of “touched end” might move outside of the if costume block if you had more conditions that also caused touched to be broadcast.
The other thing that may be happening here is that you are attempting to queue up / send several “touched end” events before you even hover the first sprite. Events have a delay and this may well make a “touched end” event get received by the sprite right after you finally send “touched” and show your speech bubble. This would make the speech bubble hide again, shortly after it was made visible.
Your script should make the speech bubble appear while hovering over the first sprite,
but your forever loop is going to be sending a very large number of messages because it will run continuously spamming the event ”touched end" once the mouse pointer is no longer touching that first sprite.
Instead of broadcasting the second event in the else condition of if touching mouse-pointer?, you would probably rather have it wait until it was no longer touching the pointer and then send the message once.
The broadcast of “touched end” might move outside of the if costume block if you had more conditions that also caused touched to be broadcast.
The other thing that may be happening here is that you are attempting to queue up / send several “touched end” events before you even hover the first sprite. Events have a delay and this may well make a “touched end” event get received by the sprite right after you finally send “touched” and show your speech bubble. This would make the speech bubble hide again, shortly after it was made visible.
Last edited by dave3m (May 7, 2022 14:52:34)
- jonasreimers123
-
4 posts
If Touching Mouse Pointer Solution.
touched end“ is probably hiding the speech bubble sprite?I'm guessing that your event "
Your script should make the speech bubble appear while hovering over the first sprite,
but your forever loop is going to be sending a very large number of messages because it will run continuously spamming the event ”touched end" once the mouse pointer is no longer touching that first sprite.
Instead of broadcasting the second event in the else condition of if touching mouse-pointer?, you would probably rather have it wait until it was no longer touching the pointer and then send the message once.
The broadcast of “touched end” might move outside of the if costume block if you had more conditions that also caused touched to be broadcast.
The other thing that may be happening here is that you are attempting to queue up / send several “touched end” events before you even hover the first sprite. Events have a delay and this may well make a “touched end” event get received by the sprite right after you finally send “touched” and show your speech bubble. This would make the speech bubble hide again, shortly after it was made visible.
THANK YOU this helped me fix my problem instantly!
- sj-error
-
1 post
If Touching Mouse Pointer Solution.
I dunno tbh
Last edited by sj-error (May 14, 2024 23:48:12)
- Discussion Forums
- » Help with Scripts
-
» If Touching Mouse Pointer Solution.