Scrolling X position and Y position
First make a variable named ScrollX and a other one called ScrollY
Make a character sprite with the following scripts
<when[ Up ]key pressed>
<change{ ScrollY }by( -10
<when[ Down ]key pressed>
<change{ ScrollY }by( 10
<when[ Right ]key pressed>
<change{ ScrollX }by( -10
<when[ Left ]key pressed>
<change{ ScrollX }by( 10
While making these scripts you can change how fast you want your character to scroll by changing the 10 on the scripts to whatever number you like.
Next make a sprite called terrain 0
with the following script
<when green flag clicked>
<forever>
<set x to( (( < { ScrollX }> <+> (( 460 <*> 0 )) ))
<set y to( (( < { ScrollY }> <+> (( 360 <*> 0 )) ))
Next make a sprite called terrain 1
with the script
<when green flag clicked>
<forever>
<set x to( (( < { ScrollX }> <+> (( 460 <*> 0 )) ))
<set y to( (( < { ScrollY }> <+> (( 360 <*> 0 )) ))
The zeros at the top could be edited to -1 , 1 anything and thats the X and Y pos of the sprite.
If you dont understand download this game and check the sprites
http://scratch.mit.edu/projects/Reamm/633116
Offline
Very helpful! Thanks for sharing.
I think you could get a slightly faster result if you used a single GOTO block instead of the two SET X and SET Y blocks. I haven't done any time trials...but it should be quicker to run one block instead of two
Offline
Does setting scroll x to 460 work properly? Because I know the length of the Scratch screen is 480 pixels.
Anyways, nice little guide you've made here.
Offline
GrammaticlyCorrect wrote:
Does setting scroll x to 460 work properly? Because I know the length of the Scratch screen is 480 pixels.
Anyways, nice little guide you've made here.![]()
It should be 480
Offline
instead of using <when[up]key pressed>
which is very crude and not very smooth, I recommend you use a script like
<when green flag clicked>
<forever>
<if><key[ up ]pressed?>
<change{ Yscroll }by( 5
<end>
<if><key[ down ]pressed?>
<change{ Yscroll }by( -5
<end>
<if><key[ right ]pressed?>
<change{ Xscroll }by( 5
<end>
<if><key[ left ]pressed?>
<change{ Xscroll }by( -5
<end>
<end>
Last edited by fireball123 (2009-08-06 11:45:59)
Offline