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

#1 2012-08-11 15:38:35

GoldTube
New Scratcher
Registered: 2012-08-07
Posts: 83

Detecting if a color has reached edge?

Is this possible?

Offline

 

#2 2012-08-11 15:54:08

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Detecting if a color has reached edge?

Not the way your wording it, but there is a way. Just follow these steps:

1). Drag the sprite with the color to the right edge of the screen.

2). From there, make it so that your color is 1 pixel away from the right edge of the screen.

3). Record the sprite's x position.

4). From there, you'll have to repeat steps 1-3 with the left side of the screen. Remember that you'll need to know which numbers are which as this will be important in the following steps.

5). Repeat steps 1-3 with the top and bottom edge of the screen, but now in step 3, you'll record the y position of the sprite.

6). Replace the variables in this script with the corresponding numbers while leaving alone the (x position) variables and the (y position) variables:

<<<(left-most x position) > (x position)> or <(right-most x position) < (x position)>> or <<(top-most y position) < (y position)> or <(bottom-most y position) > (y position)>>>
7). Now your done! The script that you just filled out is what you'll use to figure out if your color is touching the edge of the screen.

I hope that this helps!

Last edited by ErnieParke (2012-08-11 15:59:43)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-08-11 17:00:06

maxamillion321
Scratcher
Registered: 2011-06-17
Posts: 500+

Re: Detecting if a color has reached edge?

Yeah there is.

when gf clicked
if <touching color>

Offline

 

Board footer