This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-07-13 15:09:00

funky7448
New Scratcher
Registered: 2011-07-10
Posts: 4

How do I make the background change.

I am creating a game that has the character traveling through different scenes.  How do I make the background change when the character gets to the edge of his current background?  I'm thinking something like "If sprite 1 is touching edge, change background".  I can not seem to find a way to do that.

Offline

 

#2 2011-07-13 15:09:33

peterkap
Scratcher
Registered: 2009-01-24
Posts: 1000+

Re: How do I make the background change.

This has nothing to do with advanced topics.

Offline

 

#3 2011-07-13 15:12:29

funky7448
New Scratcher
Registered: 2011-07-10
Posts: 4

Re: How do I make the background change.

Thanks.  Where should I post it?

Offline

 

#4 2011-07-13 15:35:12

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: How do I make the background change.

It should go in All About Scratch.  I'll move it there for you.

To do what you want, you might want to use Broadcast Messages.  Have the sprite check to see when it is touching an edge or has an X position greater than a given value, and then have it send a message.  The stage can be set up to receive the message and do the background change.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#5 2011-07-13 15:39:54

Rosie906
Scratcher
Registered: 2011-04-09
Posts: 100+

Re: How do I make the background change.

Hey, I have an idea! How about making a variable. That way, you could do this:
When Flag Pressed,
{forever
set 'variable' to 0
if touching edge,
change variable by 1
{if variable = 1
next background}
forever}
I haven't tested it yet, but I think it'll work. Because there's a forever, the variable will always be 0 unless you touch the edge!


Be happy! Spring is coming! And spring cleaning...
http://i40.tinypic.com/9rrecj.jpg

Offline

 

#6 2011-07-13 16:07:59

funky7448
New Scratcher
Registered: 2011-07-10
Posts: 4

Re: How do I make the background change.

Thanks!  The broadcasting trick worked.  We're still figuring out variables!

Offline

 

Board footer