Discuss Scratch

Orangey2011
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

Hey everyone, I was wondering how I would be able to go to the next backdrop if a sprite touched it… I was looking at it early getting alot of it done until I found that there was no next backdrop and Sprite scripts!


Please help!

-Orangey and his buddy Mr. Block.
say [Hi! I'm Mr. Block! I protect this signature from any nasties :)] for (forever) secs
Sinaboo
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

I'll try to help.

From what I know there's 2 ways you could do this:

1. Using the if touching edge operator (Easiest)
2. Making a separate sprite that outlines the edge (Not hard but less easy)

1.
<touching [edge v] ?>

For this one you need to make it so that whenever the sprite touches the edge it will broadcast a message to the stage where the backdrops are and switch to the next backdrop.

If you still can't do it, tell me. I'll put some scratchblocks down.

Last edited by Sinaboo (Oct. 19, 2018 05:17:31)

Sinaboo
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

I think I might've found a slight flaw. If you're using the
go to [mouse pointer v]
for the sprite it might cycle through the backdrops super fast until you move it away from the edge.
Orangey2011
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

Sinaboo wrote:

I'll try to help.

From what I know there's 2 ways you could do this:

1. Using the if touching edge operator (Easiest)
2. Making a separate sprite that outlines the edge (Not hard but less easy)

1.
<touching [edge v] ?>

For this one you need to make it so that whenever the sprite touches the edge it will broadcast a message to the stage where the backdrops are and switch to the next backdrop.

If you still can't do it, tell me. I'll put some scratchblocks down.


Thanks so much!

I think that will work!

The main reason was because I couldn't go to next backdrop, but the broadcasting is a good idea!

Again, thank you alot!

-Orangey and his buddy Mr. Block.
say [Hi! I'm Mr. Block! I protect this signature from any nasties :)] for (forever) secs
Sinaboo
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

Orangey2011 wrote:

Sinaboo wrote:

I'll try to help.

From what I know there's 2 ways you could do this:

1. Using the if touching edge operator (Easiest)
2. Making a separate sprite that outlines the edge (Not hard but less easy)

1.
<touching [edge v] ?>

For this one you need to make it so that whenever the sprite touches the edge it will broadcast a message to the stage where the backdrops are and switch to the next backdrop.

If you still can't do it, tell me. I'll put some scratchblocks down.


Thanks so much!

I think that will work!

The main reason was because I couldn't go to next backdrop, but the broadcasting is a good idea!

Again, thank you alot!
You're welcome. If you didn't want to do the broadcasting thing you could've done this. All the backdrops' names would have to be numbered though (1, 2, 3, 4, 5)

when [space v] key pressed
switch backdrop to ((backdrop name) + (1))
Sinaboo
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

But you'd replace the “when space key pressed” with “touching edge” and all that. Anyways good luck on your thing.
mararocolor
Scratcher
20 posts

How do I make it go to the next backdrop if a sprite touches the edge?

adding on to what @Sinaboo said, you could also either move the sprite that touches the edge back to the middle:
go to x: (0) y: (0)
or you could use this block to make it wait until it's not touching the edge:
wait until <not <touching [edge v] ?>>
if that seems a bit too complex I could go step by step if you would like

. . . . . mararocolor's art shop |
anyways, hello, i'm mararocolor, creator of the perfect circle. . . . . . click /\
mararocolor
Scratcher
20 posts

How do I make it go to the next backdrop if a sprite touches the edge?

(also I was talking about how to get rid of the problem of it cycling through backgrounds really quickly)

. . . . . mararocolor's art shop |
anyways, hello, i'm mararocolor, creator of the perfect circle. . . . . . click /\
inferno312
Scratcher
1 post

How do I make it go to the next backdrop if a sprite touches the edge?

really its impossible iv'e searched it up on google and nothing worked and iv'e done it like 1,000,000 times
I_AM_A_BEAR_CUB
Scratcher
2 posts

How do I make it go to the next backdrop if a sprite touches the edge?

What I did was:

Make a sprite that is a sliver of the edge of the screen, and I put this:

when green flag clicked
repeat until <(backdrop #) = [2]>
if <touching color [#000000] ?> then
broadcast [ message1]
end

And for the backdrops i put
when I receive [ message1]
next backdrop

And then for the player i put
when backdrop switches to [ backdrop2]
go to x: (0) y: (0)

Last edited by I_AM_A_BEAR_CUB (Nov. 22, 2023 01:28:09)


when green flag clicked
change [ dead bodies] by (32)
forever
say [Vlad the impaler is coming for you] for (20) secs
end
I_AM_A_BEAR_CUB
Scratcher
2 posts

How do I make it go to the next backdrop if a sprite touches the edge?

Dont mind the red pieces. Theyre supposed to not be scratchblocks

when green flag clicked
change [ dead bodies] by (32)
forever
say [Vlad the impaler is coming for you] for (20) secs
end
kittyOwU
Scratcher
20 posts

How do I make it go to the next backdrop if a sprite touches the edge?

here's an idea (I don't know how these block code things work so I hope this works) ((Edit: OMG IT WORKED))
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
end
end

Last edited by kittyOwU (Nov. 22, 2023 03:54:34)


I like to code and i like to draw. _meow_ on a scratch project for a scratch cat emoji (_MEOW_ no caps)
kittyOwU
Scratcher
20 posts

How do I make it go to the next backdrop if a sprite touches the edge?

maybe add
wait (1) secs
so that the sprite has time to move before it activates the background changing thing again

I like to code and i like to draw. _meow_ on a scratch project for a scratch cat emoji (_MEOW_ no caps)
-Rabbey
New to Scratch
17 posts

How do I make it go to the next backdrop if a sprite touches the edge?

kittyOwU wrote:

here's an idea (I don't know how these block code things work so I hope this works) ((Edit: OMG IT WORKED))
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
end
end
Flaws to that, here's how to properly do it.
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
go to x: [spawn position here] y: [ground position]:: motion
end
end

Last edited by -Rabbey (Nov. 22, 2023 03:58:28)


Woah how does a New Scratcher know this much stuff?
I'm just 106809nes but on my OC's account.
existentialcrisises
Scratcher
100+ posts

How do I make it go to the next backdrop if a sprite touches the edge?

-Rabbey wrote:

-snip-
Or, if you don't want it to reset to a position, just use this:
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
wait until <not <touching [edge v]?>>
end
end
It will only change the backdrop once until you remove it from the edge.

Last edited by existentialcrisises (Nov. 22, 2023 07:04:40)


HwS Tip:
Have you ever posted some scratch blocks in the Help with Scripts forum and realised that it didn't display the way you wanted?
You can press the Preview button (the tick button) to see how your scratch blocks will turn out.
-Rabbey
New to Scratch
17 posts

How do I make it go to the next backdrop if a sprite touches the edge?

Or, if you don't want it to reset to a position, just use this:
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
wait until <not <touching [edge v]?>>
end
end
It will only change the backdrop once until you remove it from the edge.
Then you'd spawn near the edge. Maybe this:
when green flag clicked
forever
if <touching [edge v] ?> then
next backdrop
wait until <not <touching [edge v]?>>
end
set x to ()
end

Last edited by -Rabbey (Nov. 22, 2023 07:33:20)


Woah how does a New Scratcher know this much stuff?
I'm just 106809nes but on my OC's account.

Powered by DjangoBB