I was doing this project and I was wondering if there is a block that is like this:
What it would do: It would detect if the mouse is touching a color on you're sprite. If used with "if mouse down", it would detect when the mouse is clicked and if its touching the selected color.
Offline
There is a way to do this:
1. Make a sprite.
2. Give it the following script:
[blocks]<when green flag clicked>
<set[ ghost ]effect to( 100
<forever>
<go to x <mouse x> )y <mouse y>
<if><touching color[
<broadcast[ Whatever you want to happen!
<end>
<end>[/blocks]
This has the same effect. The reason I didn't select [blocks]<hide>[/blocks] is because when a sprite is hidden, it has no collision detection capabilities. Setting the ghost effect to 100 makes a sprite invisible, but it still "exists".
Offline
Nick60 wrote:
Yeah but what happens if you don't want the sprite to always go to the mouse. Just want it to recognize if the mouse is over it and over a certain color?
There is absolutely no reason to want that... by my logic.
Offline
If you're making a sprite that changes to something else and instead of making a whole new button and coding its functions, just include a little exit button. And then have it recognize if it clicks that.
Offline
big-bang wrote:
I think most of the new blocks that people are suggesting are just simplified versions of longer scripts. The only one that ISN'T is... ummm... "clone".
It's true that many people suggest blocks because they don't understand how or can't be bothered to make longer more complicated scripts. Many of the blocks already available can be made using longer scripts, but the whole point of Scratch is that it's an easy to understand and accessible program.
Personally I think that mouse related sensors would be a good idea, creating a yet another sprite seems an unwieldy solution and on larger projects, especially online ones, the mouse sprite can lag quite a bit. However, it is far from top of the list of priorities as it won't affect the majority of projects and a viable work-around is available.
Nick60 wrote:
If you're making a sprite that changes to something else and instead of making a whole new button and coding its functions, just include a little exit button. And then have it recognize if it clicks that.
If I understand correctly, you have a sprite and you want it to change when you click a little box in the corner which is another colour (let's say red). What Big-Bang was suggesting was that you create another sprite and give it that script so that whenever your mouse is over the red box the sprite will detect the red and carry out whatever action is required.
I hope that helps,
SB
Offline
big-bang wrote:
There is a way to do this:
1. Make a sprite.
2. Give it the following script:
[blocks]<when green flag clicked>
<set[ ghost ]effect to( 100
<forever>
<go to x <mouse x> )y <mouse y>
<if><touching color[
<broadcast[ Whatever you want to happen!
<end>
<end>[/blocks]
This has the same effect. The reason I didn't select [blocks]<hide>[/blocks] is because when a sprite is hidden, it has no collision detection capabilities. Setting the ghost effect to 100 makes a sprite invisible, but it still "exists".
You can also replace the [blocks]<touching color[ [/blocks] with [blocks]<touching[ [/blocks]. If you want more than one sprite to be sensed, use [blocks]<< <or> >>[/blocks].
Offline