Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Problems I am having with deleting clone
- sloppy_floppy
-
Scratcher
3 posts
Problems I am having with deleting clone
when I start as a clone
repeat until <(x position) < [-344]>
change x by (-5)
if <(x position) = [-80]> then
play sound [... v]
change [score v] by (1)
end
end
delete this clone
Why is it not delete this clone tho?
Last edited by sloppy_floppy (May 11, 2024 12:00:34)
- sloppy_floppy
-
Scratcher
3 posts
Problems I am having with deleting clone
and also why is it not playing the sound and change score?
- Za-Chary
-
Scratcher
1000+ posts
Problems I am having with deleting clone
It depends somewhat on the size of the sprite, but many sprites cannot go left beyond an x position of -240. Since your “repeat until” block is waiting for the x position to be less than -344, this will likely never happen.
To fix it, try replacing -344 with something like -200 and see if that works. If it does, you can decrease -200 slightly to -220, -230, etc. until you find a number that works which you are happy with.
To fix it, try replacing -344 with something like -200 and see if that works. If it does, you can decrease -200 slightly to -220, -230, etc. until you find a number that works which you are happy with.
- Za-Chary
-
Scratcher
1000+ posts
Problems I am having with deleting clone
and also why is it not playing the sound and change score?As for this: it depends on where your sprite starts. If it starts at an x position of 2, for instance, then since x is always changing by -5, its subsequent positions will be:
-3, -8, -13, -18, -23, -28, -33, -38, -43, -48, -53, -58, -63, -68, -73, -78, -83, -88, …
As you can see, due to the nature of the script, this sprite would actually never hit an x position of -80; it will completely pass by. You would need to find some sort of workaround to make sure that your sprite will actually hit this position.
- CST1229
-
Scratcher
1000+ posts
Problems I am having with deleting clone
(#4)Or you can make it not just exactly check for x -80, like this: EDIT: but then it'd play the sound and change score multiple times, so you't have to find a way to make it only run once or make the range smaller:
As you can see, due to the nature of the script, this sprite would actually never hit an x position of -80; it will completely pass by. You would need to find some sort of workaround to make sure that your sprite will actually hit this position.
// checks if the x position is within 10 pixels of -80.
// the (abs of ()) block makes negative numbers positive, so, for example, -5 becomes 5
if <([abs v] of ((x position) - (-80))) < (5)> then
play sound [... v]
change [score v] by (1)
end
Last edited by CST1229 (May 11, 2024 12:36:18)
- Discussion Forums
- » Questions about Scratch
-
» Problems I am having with deleting clone
