Hi,
is it possible, to activate a script when an object is hovering over another object? We want to play a sound when an object is moved by the player over another object, but this only works when you click on it.
This is what we have:
when object1 clicked forever forever if touching object2? play sound1 until doneYou can drag the Object1 with your mouse, but the sound only plays when you let go while its over object2 and click on object2. We want the sound to play while object1 is hovering over object2. Is that possible in Scratch?
Offline
You could make a sprite shaped like a box. Then put that sprite in the area over the one object you want to have something hovering over.
Then make the box invisible by using the set [ghost] effect to 100 block. Make sure the box is small enough that to be touching it a sprite has to be completely overtop the one object you want it to be hovering over.
Then have the sound play when the one object/sprite is touching the box sprite you made. Make sense?
Offline
dusty22 wrote:
Then have the sound play when the one object/sprite is touching the box sprite you made. Make sense?
Wouldnt you need to click on it as well? Or does it work differently with invisible objects?
Offline
Oh, I think I understand now. I'm not sure, generally in Scratch it seems to me when you're holding a sprite via the mouse it doesn't run its scripts or have normal properties. If you could have it move via the arrow keys or another method it'd definately work. I'm not sure about using the mouse though.
Try having the script cue from the Green Flag being clicked, and then have it run that script by checking to see if the mouse is being clicked with.
Like this:
when gf clicked forever if <mouse down> if <touching [mouse-pointer v]> if <touching object2?> play sound1 until done end end endTry something like that.
Last edited by dusty22 (2013-04-05 17:41:15)
Offline
Hello,
My little sister and I tried your scripts (xlk, dusty22), but it still only plays the sound when the player places Object1 on Object2 and then clicks on Object1 ...
I guess, i will now have to explain to my sister she must use the arrow keys instead...
Thank you all for your help!
Offline