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

#1 2011-03-19 12:00:16

3DBlenderRender
Scratcher
Registered: 2011-03-10
Posts: 44

Scrolling Question

Hi, fellow Scratchers,

I was working on a sequel to one of my projects and it'll be a scrolling game. It's and up/down scroller, and the controls for character movement and scrolling movement are separate. As those who've made scrollers know, the sprites catch on the edges of the stage, rather than disappear. I realize I could simply make a "Hide if Touching Screen Edge", but then it doesn't reserve the position the sprite was in.

How can I fix this? It's getting to be a pain.

- 3DBlenderRender

Offline

 

#2 2011-03-19 12:11:31

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: Scrolling Question

Make a variable called xpos. Then, set xpos to the starting x position. Then, lets say the sprite moves by 10 when the right key is pressed. When you move by 10, also change xpos by 10, and when you move by -10, change xpos by -10. Then make the sprite hide when xpos is 240 or more or -240 or less. When xpos is between -240 and 240, the sprite should show. Then, when the sprite is hidden and you continue to press the right (or left) arrow key, it continues to change xpos. I hope this helps.  smile


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#3 2011-03-19 12:13:55

3DBlenderRender
Scratcher
Registered: 2011-03-10
Posts: 44

Re: Scrolling Question

scratcher7_13 wrote:

Make a variable called xpos. Then, set xpos to the starting x position. Then, lets say the sprite moves by 10 when the right key is pressed. When you move by 10, also change xpos by 10, and when you move by -10, change xpos by -10. Then make the sprite hide when xpos is 240 or more or -240 or less. When xpos is between -240 and 240, the sprite should show. Then, when the sprite is hidden and you continue to press the right (or left) arrow key, it continues to change xpos. I hope this helps.  smile

Perfect, just what I needed. Of course, I'll have to make it -240 + Variable P and 240 + Variable P, as the object is a moving CPU. Thanks so much!

- 3DBlenderRender

Offline

 

#4 2011-03-19 12:18:40

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: Scrolling Question

You are welcome!  cool


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

Board footer