Discuss Scratch
- Discussion Forums
- » Suggestions
- » touching edge of sprite
- CodeKing_11
-
Scratcher
100+ posts
touching edge of sprite
So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:
repeat until <touching edge of [ v] ?>
change y by (-1)
end
Last edited by CodeKing_11 (Oct. 3, 2024 21:08:28)
- happywaffle0
-
Scratcher
100+ posts
touching edge of sprite
So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:repeat until <touching edge of [ v] ?>
change y by (-1)
end
The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
- CodeKing_11
-
Scratcher
100+ posts
touching edge of sprite
It would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:repeat until <touching edge of [ v] ?>
change y by (-1)
end
The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
Last edited by CodeKing_11 (Oct. 3, 2024 21:16:59)
- happywaffle0
-
Scratcher
100+ posts
touching edge of sprite
It would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
what about the y coordinate?
Last edited by happywaffle0 (Oct. 3, 2024 21:19:47)
- CodeKing_11
-
Scratcher
100+ posts
touching edge of sprite
Same thingIt would be the last x coordinate before it is no longer touching the art of the sprite. Lets say I had a circle, and a dot in it. If I wanted the dot to move until it's at the edge of the circle, it would be a repeat with this new boolean, and once it cannot go anymore unless it isn't touching the sprite, it stops.So if you use this boolean on an “if” or “repeat until” block ,it will wait until one sprite is touching the edge of another sprite. This could be used for bouncing on sprites easier if a sprite is moving consistently. it would be in the sensing category as a boolean. it would look something like this:repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
The question(s) is, what will define as a “edge” of a sprite be? What about the curves and such? Will those be counted as edges? How will this be coded?
what about the y coordinate?
- han614698
-
Scratcher
1000+ posts
touching edge of sprite
but what's wrong with just doing this
repeat until <touching [ v] ?::sensing>instead of
change y by (-1)
end
repeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
- CodeKing_11
-
Scratcher
100+ posts
touching edge of sprite
but what's wrong with just doing thiswhat if the middle is colored? That would be part of the sprite, making it just stay putrepeat until <touching [ v] ?::sensing>instead of
change y by (-1)
endrepeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
- cookieclickerer33
-
Scratcher
1000+ posts
touching edge of sprite
but what's wrong with just doing thiswhat if the middle is empty? That wouldnt be part of the sprite, making it just stay putrepeat until <touching [ v] ?::sensing>instead of
change y by (-1)
endrepeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
I think I fixed your question.
If the meddle of a sprite is transparent this method won’t work because the sprite would think the transparent area is the edge
- CodeKing_11
-
Scratcher
100+ posts
touching edge of sprite
I said the last x before it is touching outside of the sprite. For example:but what's wrong with just doing thiswhat if the middle is empty? That wouldnt be part of the sprite, making it just stay putrepeat until <touching [ v] ?::sensing>instead of
change y by (-1)
endrepeat until <touching edge of [ v] ?::sensing>
change y by (-1)
end
I think I fixed your question.
If the meddle of a sprite is transparent this method won’t work because the sprite would think the transparent area is the edge
(vertical line = edge, horizontal line = sprite)
| – : False
|– : True
Last edited by CodeKing_11 (Oct. 8, 2024 15:07:17)
- Discussion Forums
- » Suggestions
-
» touching edge of sprite



