Discuss Scratch

5ln73935
Scratcher
5 posts

How to make it so when a sprite touches the end it changes to another background

I have no idea how to make it so that when my sprite touches the end it goes to another background
bRuHbRuHmEmEmAn
Scratcher
500+ posts

How to make it so when a sprite touches the end it changes to another background

5ln73935 wrote:

I have no idea how to make it so that when my sprite touches the end it goes to another background
By end, do you mean the edge? If so, here's a way to do it.
when gf clicked
forever
if <touching [edge v]?> then
next backdrop
wait until <not <touching [edge v]?>>
end
end
5ln73935
Scratcher
5 posts

How to make it so when a sprite touches the end it changes to another background

Thanks for the info also yes I meant edge but when I'm using it it keeps going into a loop how to make it so that it doesnt keep going and stops at a certain one.

Last edited by 5ln73935 (Jan. 21, 2024 02:01:03)

chippysmall4
Scratcher
1000+ posts

How to make it so when a sprite touches the end it changes to another background

Don't use
next backdrop
Use A Variable Called Stage
In Backdrop
when green flag clicked
set [ Stage] to [1]
when I receive [next stage]
switch backdrop to (Stage)
In Player:
when green flag clicked
forever
if <[(x position)] > [239]> then
set x to (-239)
change [Stage] by (1)
broadcast [Next Stage]
end
if <[(x position)] < [-239]> then
set x to (239)
change [Stage] by (-1)
broadcast [Next Stage]
end

Last edited by chippysmall4 (Jan. 21, 2024 06:03:30)

5ln73935
Scratcher
5 posts

How to make it so when a sprite touches the end it changes to another background

didnt work
chippysmall4
Scratcher
1000+ posts

How to make it so when a sprite touches the end it changes to another background

5ln73935 wrote:

didnt work
Check If You Matched The Code.
pythonicKI
Scratcher
100+ posts

How to make it so when a sprite touches the end it changes to another background

chippysmall4 wrote:

(#4)
Don't use
next backdrop
Use A Variable Called Stage
In Backdrop
when green flag clicked
set [ Stage] to [1]
when I receive [next stage]
switch backdrop to (Stage)
In Player:
when green flag clicked
forever
if <[(x position)] > [239]> then
set x to (-239)
change [Stage] by (1)
broadcast [Next Stage]
end
if <[(x position)] < [-239]> then
set x to (239)
change [Stage] by (-1)
broadcast [Next Stage]
end
Why don't use next backdrop?

5ln73935 wrote:

(#3)
Thanks for the info also yes I meant edge but when I'm using it it keeps going into a loop how to make it so that it doesnt keep going and stops at a certain one.
Do this instead:

when gf clicked
forever
if <touching [edge v]> then
next backdrop
stop [this script v]

So the loop stops after the backdrop changes.
chippysmall4
Scratcher
1000+ posts

How to make it so when a sprite touches the end it changes to another background

pythonicKI wrote:

chippysmall4 wrote:

(#4)
Don't use
next backdrop
Use A Variable Called Stage
In Backdrop
when green flag clicked
set [ Stage] to [1]
when I receive [next stage]
switch backdrop to (Stage)
In Player:
when green flag clicked
forever
if <[(x position)] > [239]> then
set x to (-239)
change [Stage] by (1)
broadcast [Next Stage]
end
if <[(x position)] < [-239]> then
set x to (239)
change [Stage] by (-1)
broadcast [Next Stage]
end
Why don't use next backdrop?

5ln73935 wrote:

(#3)
Thanks for the info also yes I meant edge but when I'm using it it keeps going into a loop how to make it so that it doesnt keep going and stops at a certain one.
Do this instead:

when gf clicked
forever
if <touching [edge v]> then
next backdrop
stop [this script v]

So the loop stops after the backdrop changes.
Stopping the Script Means They Can't Change The Level Again.
Using A Variable Means That The Level Can Be Easily Toggled
HYTHON123
Scratcher
22 posts

How to make it so when a sprite touches the end it changes to another background

this is how you do it

when green flag clicked
forever
if <(x position) > > then
switch backdrop to
end
end

HYTHON123
Scratcher
22 posts

How to make it so when a sprite touches the end it changes to another background

when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
stop [this script v]
end
end
DogeMeowy
Scratcher
100+ posts

How to make it so when a sprite touches the end it changes to another background

pythonicKI wrote:

chippysmall4 wrote:

(#4)
Don't use
next backdrop
Use A Variable Called Stage
In Backdrop
when green flag clicked
set [ Stage] to [1]
when I receive [next stage]
switch backdrop to (Stage)
In Player:
when green flag clicked
forever
if <[(x position)] > [239]> then
set x to (-239)
change [Stage] by (1)
broadcast [Next Stage]
end
if <[(x position)] < [-239]> then
set x to (239)
change [Stage] by (-1)
broadcast [Next Stage]
end
Why don't use next backdrop?

5ln73935 wrote:

(#3)
Thanks for the info also yes I meant edge but when I'm using it it keeps going into a loop how to make it so that it doesnt keep going and stops at a certain one.
Do this instead:

when gf clicked
forever
if <touching [edge v]> then
next backdrop
stop [this script v]

So the loop stops after the backdrop changes.
try
if <touching [edge v]> then
next backdrop
move (-10) steps
jakob_sigmaohio
New Scratcher
1 post

How to make it so when a sprite touches the end it changes to another background

.

Last edited by jakob_sigmaohio (March 17, 2026 11:53:49)

Powered by DjangoBB