This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-01-04 11:31:08

Nick60
Scratcher
Registered: 2007-06-17
Posts: 100+

New Block [Mouse is touching]

I was doing this project and I was wondering if there is a block that is like this:

http://img26.picoodle.com/img/img26/3/1/4/f_1m_5cc48fc.png

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.


Let's  Be Blue!

Offline

 

#2 2009-01-04 11:44:24

726961
Scratcher
Registered: 2008-11-26
Posts: 100+

Re: New Block [Mouse is touching]

m44 did a mouse maze. You should make a sprite that is always where the mouse is than that is what would be touching a color


http://scratch.mit.edu/projects/726961/604658 play it now! or else...

Offline

 

#3 2009-01-04 12:28:35

big-bang
Scratcher
Registered: 2008-02-21
Posts: 1000+

Re: New Block [Mouse is touching]

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 sad  <mouse x> )y sad  <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".


http://i47.tinypic.com/6edrbm.jpghttp://i45.tinypic.com/dw9hmw.jpghttp://i50.tinypic.com/f28tvn.jpghttp://i45.tinypic.com/ruwaop.jpg

Offline

 

#4 2009-01-04 12:51:10

Nick60
Scratcher
Registered: 2007-06-17
Posts: 100+

Re: New Block [Mouse is touching]

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?


Let's  Be Blue!

Offline

 

#5 2009-01-04 12:58:26

big-bang
Scratcher
Registered: 2008-02-21
Posts: 1000+

Re: New Block [Mouse is touching]

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.


http://i47.tinypic.com/6edrbm.jpghttp://i45.tinypic.com/dw9hmw.jpghttp://i50.tinypic.com/f28tvn.jpghttp://i45.tinypic.com/ruwaop.jpg

Offline

 

#6 2009-01-04 13:00:12

Nick60
Scratcher
Registered: 2007-06-17
Posts: 100+

Re: New Block [Mouse is touching]

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.


Let's  Be Blue!

Offline

 

#7 2009-01-04 14:08:16

big-bang
Scratcher
Registered: 2008-02-21
Posts: 1000+

Re: New Block [Mouse is touching]

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".


http://i47.tinypic.com/6edrbm.jpghttp://i45.tinypic.com/dw9hmw.jpghttp://i50.tinypic.com/f28tvn.jpghttp://i45.tinypic.com/ruwaop.jpg

Offline

 

#8 2009-01-04 14:40:57

ScipioBellorum
Scratcher
Registered: 2007-05-15
Posts: 94

Re: New Block [Mouse is touching]

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


http://img393.imageshack.us/img393/339/logory8.png
                      The word processor for Scratch

Offline

 

#9 2009-01-04 14:45:55

Nick60
Scratcher
Registered: 2007-06-17
Posts: 100+

Re: New Block [Mouse is touching]

I knew how to do that, but many projects that simulate operating systems have to create so many sprites.  Also other big projects as you said.


Let's  Be Blue!

Offline

 

#10 2009-01-04 16:15:37

big-bang
Scratcher
Registered: 2008-02-21
Posts: 1000+

Re: New Block [Mouse is touching]

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 sad  <mouse x> )y sad  <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].


http://i47.tinypic.com/6edrbm.jpghttp://i45.tinypic.com/dw9hmw.jpghttp://i50.tinypic.com/f28tvn.jpghttp://i45.tinypic.com/ruwaop.jpg

Offline

 

Board footer