Discuss Scratch

Tatchka
New Scratcher
3 posts

how to change backdrop after reaching an x point

quick question, what code do you use to make the backdrop change after you reached a certain x point to make it look like you've went into another room?
abcde1234qwe
Scratcher
500+ posts

how to change backdrop after reaching an x point

You can use an if block with an operator that detects if the x position is less than or greater than the needed position to go into another room.
when green flag clicked
forever
if <(x position) > [200]> then//This detects if the sprite is on the right side of the screen.
switch costume to [backdrop v]
set x to (-195)
end
if <(x position) < [-200]> then//This detects if the sprite is on the left side of the screen.
switch costume to [backdrop v]
set x to (195)
end
end
cIoudyness
Scratcher
500+ posts

how to change backdrop after reaching an x point

hmm another idea:
repeat until <>
if <([abs v] of (x position)) > [200]> then
insert backdrop script from below here!
set x to ((round ((x position) / (200))) * (-200))
wait until <not <([abs v] of (x position)) = [200]>
end
end
this code looks nice and fancy and works for both sides - going to a room on the left and the right.
here’s some scripts that you can use to switch the backdrop both left and right
switch backdrop to ((backdrop #) + ((<(x position) > [0]> * [2]) - [1]) 

if <(x position) > [0] > then
next backdrop
else
switch backdrop to ((backdrop #) - [1])
end

Last edited by cIoudyness (July 6, 2022 02:13:14)

Powered by DjangoBB