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

#1 2010-04-18 11:46:30

SammyJames
Scratcher
Registered: 2010-04-11
Posts: 6

Changing Backgrounds

I'm currently in the middle of creating a game with a bird's-eye-view. Basically, you'll be looking down on the main character and his adventures throughout. What I'm having a problem with is that I have many backgrounds(rooms) to enter and I can't use the scripts with
                               "if touching color _"
                             "change to background _"

With all the different backgrounds(rooms) I have planned for this project, I'd eventually run out of colors, not to mention the colors I've already used to paint the backgrounds themselves. I need a script that will allow me to go the edge of the background screen, whether it be the top, left, right, or bottom edge and once I reach that edge to go the appropriate screen that I have broadcasted for it.

For example,

                           "if touching left edge of background 1"
                            "change to backround 2"

Do I need to make a variable for this?
Any help would be greatly appreciated.

Offline

 

#2 2010-04-18 12:23:30

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

Re: Changing Backgrounds

Lists are a good approach here...I've got an example that uses lists to keep track of what the neighbor backgrounds are for the four possible directions...

http://scratch.mit.edu/projects/Paddle2SeeFixIt/832535


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

Offline

 

#3 2010-04-18 12:42:42

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: Changing Backgrounds

If i'm doing stuff like this I normally use sensors. Just make it as long as the little door is and name it as it's room. For example if I wanted to make a room sensor for the town hall, then I would call it "town hall sensor".

Then put on the sensor

When green flag clicked
Forever
set ghost effect to 100
--

And then on your little mover, do exaclty your code except do

If touching sprite : Sensor

than

If touching colour.


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

#4 2010-04-18 12:48:51

climber59
Scratcher
Registered: 2009-12-15
Posts: 100+

Re: Changing Backgrounds

You can use

<if> <(<x position> <>> 235 )>

Last edited by climber59 (2010-04-18 12:54:58)


Check out my projects if you have a chance.

Offline

 

#5 2010-04-18 13:06:54

Stickman704
Scratcher
Registered: 2009-01-31
Posts: 1000+

Re: Changing Backgrounds

climber59 wrote:

You can use

<if> <(<x position> <>> 235 )>

That would probably be too complicated. You'd have to figure out the x position then put it in. It is a way though.


Dun dun dun dun dun dun.... dun dun dun dun dun dun...  tongue

Offline

 

Board footer