If you want to make the background scroll either make sprites behind your character move in the opposite direction that s/he is moving, make the background switch backgrounds that create the same illusion or do both. Or if you want to make a force scrolling game do the same thing just don't make it interact with the main character
Offline
First make 2 sprites. One for scrolling and one that's background size.
Then, make a variable called Scroll X. Make sure it's for all sprites. Make the following script:
<when green flag clicked>
<forever>
<set x to( (( <{ Scroll X }> <+> 480 ))
<end>
<when green flag clicked>
<forever>
<set x to( (( <{ Scroll X }> <+> (( 480 <*> 0 )) ))
<end>
Those ones are for the sprite for scrolling.
For the one that's background size, make these scripts:
<when green flag clicked>
<forever>
<set x to( (( <{ Scroll X }> <+> 980 ))
<end>
<when green flag clicked>
<forever>
<set x to( (( <{ Scroll X }> <+> (( 480 <*> 1 )) ))
<end>
If you want to make the scrolling effect restart once it's reached the end, simply make an exact duplicate of the background size sprite and make it appear last. Finally, make this script:
<when green flag clicked>
<forever>
<if> <( <x position> <<> 0 )>
<set{ Scroll X }to( 0
<end>
<end>
If you want your background sized sprite to scroll to the left, Scroll X needs to be changed by a negative number and when scrolling to the right, Scroll X needs to be changed by a positive number. Got it?
I hope this helps!
Last edited by Chatter (2010-01-09 18:49:36)
Offline
articsky wrote:
at this time today i start my scrolling game weeeeee
Good luck on it! If there is a problem or you need help, feel free to ask me!
Offline
articsky wrote:
ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh : it did not work!!!!
That's too bad. Try redoing it, or asking more experienced Scratchers for help.
Offline
wait a minute me got idea do you have any scroling games if so i can study it and make my own. LOL.
Offline
articsky wrote:
wait a minute me got idea do you have any scroling games if so i can study it and make my own. LOL.
Not really. I know scrolling but I never use it. But I also know this Scratcher, FMT who makes a ton of scrolling projects. Maybe it'll help you. Here's the link to his profile: http://scratch.mit.edu/users/floatingmagictree
Offline
it's so sad i failed look at it in my profile its called false scrolling game
Offline
Here's a scrolling engine using one sprite for the character (no hit test sprites) and 2 sprites for terrain, you can use it but give credit to me and RHY3756547:
http://scratch.mit.edu/projects/juststickman/869679
(edit the costumes, both land sprites have to have costumes in the same order)
Offline
Scrolling has one main variable, Scroll X. This variable records where you are on the area.
There are many ways to do scrolling. Here's the compact way, with two sprites for the terrain. The variables:
Scroll X: The usual variable that keeps track of where you are, nothing big.
Terrain number: The variable that tells the terrain sprites what costume to be in.
You need to have several costumes for each terrain sprite; they're going to be the only terrain sprites, so you'll have to re-use them.
There's an easier way to do scrolling, but with many sprites for the terrain. No terrain sprites are re-used - which means that the variable Terrain Number isn't needed.
You'll have noticed one thing we're missing - the script that sets the Scroll X variable! Well, there are two ways: One with velocity, and one without. Here are the two scripts:
And that's it. Some tutorials for scrolling:
archmage's Scrolling Done Right (many-sprite scrolling)
archmage's Efficient Scrolling Demo (two-sprite scrolling) (not exactly a tutorial, but you can download the project and take a look)
Any questions?
Last edited by Jonathanpb (2010-02-07 23:39:27)
Offline
I don't understand!!! Is there a simpler way?!? PLEASE SAY THERE IS!
Offline
Unfortunately, there isn't a simpler way. Scrolling is a tough thing; take a look at my post on this topic.
Offline
invinceableian wrote:
I don't understand!!! Is there a simpler way?!? PLEASE SAY THERE IS!
As JeanTheFox said, scrolling games are not easy. Try taking a look at my scrolling demo: http://scratch.mit.edu/projects/Thomas96/1206903 :
Offline
make a varieable called scrollxhttp://scratch.mit.edu/forums/viewtopic.php?pid=477814#req_message<{ }>
Offline