Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » switching to a backdrop when x= a certain position as rooms
- Murphy1214
-
Scratcher
4 posts
switching to a backdrop when x= a certain position as rooms
I'm making a game https://scratch.mit.edu/projects/1231238855/ and I want to have the character go to a certain x position and then it will switch the backdrop like a room can somebody help?
- Catscratcher07
-
Scratcher
1000+ posts
switching to a backdrop when x= a certain position as rooms
In your main loop, constantly check for x being greater than a certain value (do not use equals since you cannot guarantee the player will be at an exact position), and if so, set the player's x and y to wherever you want them to start a room at and change the backdrop.
- KMFpenguin
-
Scratcher
100+ posts
switching to a backdrop when x= a certain position as rooms
when green flag clicked
forever
if <<(x position) > [#]> and <(x position) < [#]>> then
switch backdrop to [the backdrop you want v]
end
Like Catscratcher07 said, you don't want the location to be too precise so probably give it a range like in this code. (This is basically what they said only explained in scratchblocks)
- chocoman11
-
Scratcher
8 posts
switching to a backdrop when x= a certain position as rooms
Like in a Zelda or Metroid type game? Because then I would check if your x/y position is more than, for example, 200, then it will change a variable for the room x/y coordinates, like so:
Then you name your room costumes after the respective coordinates(and if you are making a Metroid game with multiple areas, you could also add an area variable and add that to the costume name). Then, add a script like this:
Example is supposed to have a two join blocks instead and three variables instead of a text field, but I can't figure out how to make it the blocks.
Hopefully this helps!
if <(<[X position v] of [Player v] > > [200])> then
change [roomX v] by (1)
end
Then you name your room costumes after the respective coordinates(and if you are making a Metroid game with multiple areas, you could also add an area variable and add that to the costume name). Then, add a script like this:
forever
switch costume to [(join (roomX) (join (roomY) (area))]
end
Example is supposed to have a two join blocks instead and three variables instead of a text field, but I can't figure out how to make it the blocks.
Hopefully this helps!
- Discussion Forums
- » Help with Scripts
-
» switching to a backdrop when x= a certain position as rooms



