Discuss Scratch
- Discussion Forums
- » Suggestions
- » Edge
- secretuch
-
Scratcher
500+ posts
Edge
No support because there is a workaround
if on edge, bounce
insert blocks here:: stack grey
- Za-Chary
-
Scratcher
1000+ posts
Edge
No support because there is a workaroundThis is actually not a workaround. Suppose you wanted to make a sprite bounce off the walls, and every time it does, it changes color (and doesn't change color until it bounces off a wall). This would work if you run the following code using the OP's proposed block:if on edge, bounce
insert blocks here:: stack grey
turn cw (45) degrees
forever
move (5) steps
if on edge, bounce and{
change [color v] effect by (50)
} :: motion
end
However, the following blocks using your proposed workaround would case the sprite to always change color, even when it is not currently bouncing off of a wall (try it to see what happens):
turn cw (45) degrees
forever
move (5) steps
if on edge, bounce
change [color v] effect by (50)
end
The “if on edge, bounce” block is kind of interesting because there is an “if” statement that is confined to that block only. No other actions can be associated to the “if” statement in this particular block. That's why the OP's suggestion has merit.
- cutellama12345
-
Scratcher
100+ posts
Edge
You could just do
if on edge, bounce
if <touching edge> then
do whatever you want to do
end
- Za-Chary
-
Scratcher
1000+ posts
Edge
You could just doInterestingly, this doesn't work either. I just tried it using my post above as a basis:if on edge, bounce
if <touching edge> then
do whatever you want to do
end
turn cw (45) degrees
forever
move (5) steps
if on edge, bounce
if <touching [edge v]?> then
change [color v] effect by (50)
end
end
Try it out yourself: the sprite will sometimes change color when it touches the edge, but not 100% of the time it touches the edge. This seems a little counterintuitive. Maybe it's a bug? Or it just further cements the idea that “if on edge, bounce” is its own entity.
Last edited by Za-Chary (July 16, 2026 14:05:00)
- 4022201
-
Scratcher
39 posts
Edge
you cant just do:
edit:
foreveras a workaround?
wait until <touching [edge v] ?>
if on edge, bounce
...
edit:
forever
repeat until <touching [edge v] ?>
move (5) steps
end
if on edge, bounce
...
end
Last edited by 4022201 (July 16, 2026 15:35:41)
- Za-Chary
-
Scratcher
1000+ posts
Edge
- snip -This doesn't work because it often changes color twice while it bounces (that is, the color effect often changes by 100 rather than 50):
forever
repeat until <touching [edge v] ?>
move (5) steps
end
if on edge, bounce
change [color v] effect by (50)
end
- scratchy_boy106
-
Scratcher
1000+ posts
Edge
when green flag clicked
forever
move (10) steps
if <touching [edge v] ?> then
if on edge, bounce
change [color v] effect by (25)
end
end
Last edited by scratchy_boy106 (Yesterday 11:28:05)
- Discussion Forums
- » Suggestions
-
» Edge