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

#1 2012-02-17 15:39:50

Smileyspongebob
Scratcher
Registered: 2011-11-10
Posts: 90

Scrolling

Well, I already asked if it was possible, and I have had the definition from Scratch Wiki, but it just confused me! How do you make a game where scenery comes towards you? Like walking around a town or something, from the main characters point of view. Please help! I really need to know how  big_smile  thanks!


http://i48.tinypic.com/2hn5eo9.png

Offline

 

#2 2012-02-17 15:58:27

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Scrolling

OK, first you need to create a variable:

 (scrollx) 
This variable is going to tell you where your character is in the larger map.  Usually, you use the actual x and y values of the sprite, but in this case, since the map is moving instead of the sprite, the sprite stays at 0,0 and "moves" by changing this variable.

Then, all of your background sprites need to move according to your variable.  To do this, they go to the opposite x position.  This way, when you change the x value by a positive value, it looks like you move forward instead of backward.

Then you put normal moving scripts in your character EXCEPT change out any blocks controlling motion to blocks controlling your variable.

After you do this, experiment with ways to do "wrapping" which is where your background sprites can be used as multiple "tiles" in your map.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2012-02-19 09:53:54

Smileyspongebob
Scratcher
Registered: 2011-11-10
Posts: 90

Re: Scrolling

AtomicBawm3 wrote:

OK, first you need to create a variable:

 (scrollx) 
This variable is going to tell you where your character is in the larger map.  Usually, you use the actual x and y values of the sprite, but in this case, since the map is moving instead of the sprite, the sprite stays at 0,0 and "moves" by changing this variable.

Then, all of your background sprites need to move according to your variable.  To do this, they go to the opposite x position.  This way, when you change the x value by a positive value, it looks like you move forward instead of backward.

Then you put normal moving scripts in your character EXCEPT change out any blocks controlling motion to blocks controlling your variable.

After you do this, experiment with ways to do "wrapping" which is where your background sprites can be used as multiple "tiles" in your map.

........ That may take a while to sink in XD, i'll try it, thanks!  big_smile


http://i48.tinypic.com/2hn5eo9.png

Offline

 

Board footer