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

#1 2010-09-29 15:38:34

JoeHScratch
New Scratcher
Registered: 2010-09-28
Posts: 2

A problem with vertical scrolling

I'm not sure if this is belongs in the "advanced" section or not, but I am having trouble with scrolling. I got it to scroll fine, however my obstacles that are above 170 on the y axis (I'm not exactly sure what the number value is that is the top of the screen) all pile up at the very top and stay there until my scroll number is high enough. I want them to stay off screen however like in the horizontal scrolling examples and tutorials where the sprites remain off screen and don't pile up on the side. Not sure what to do.

Offline

 

#2 2010-09-29 15:46:37

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: A problem with vertical scrolling

If y > 150
hide
else
show


You can now reach me on Twitter @johnnydean1_

Offline

 

#3 2010-09-29 17:05:36

JoeHScratch
New Scratcher
Registered: 2010-09-28
Posts: 2

Re: A problem with vertical scrolling

johnnydean1 wrote:

If y > 150
hide
else
show

But I also want it to hide again once it gets gets too low as it piles up there too. If I tell it to hide in both places but show elsewhere it gets confused and blinks rapidly.

Offline

 

#4 2010-10-02 05:07:18

subzerostig
Scratcher
Registered: 2010-09-08
Posts: 100+

Re: A problem with vertical scrolling

There is an alternative which is probably just as good. simply create a sprite that covers up the bit at the bottom and top. The reason for the problem is that when each sprites ends on the demo it is exactly the same level so you don't get that problem. See my horizontal scrolling game called helicopter game. (I don't know how to create a "link to project" on scratch.


There are 10 types of people people in this world, those that understand binary and those that do not: My latest Project: Present catcher V2                          06/12/2012

Offline

 

#5 2010-10-02 05:26:22

subzerostig
Scratcher
Registered: 2010-09-08
Posts: 100+

Re: A problem with vertical scrolling

I think you only need 1 if,else block.
Think about it if its at the top then the block which knows it is at the top will hide it but then then the other if,else block will show it as it isn't at the bottom
Try this code:

<when green flag clicked>
<forever>
<if<<<( <y position> <>>150 )>  <or><(<y position>  <<> 50 )>  >>>
<show>
<else>
<hide>
<end>

Hope it helps.  big_smile


There are 10 types of people people in this world, those that understand binary and those that do not: My latest Project: Present catcher V2                          06/12/2012

Offline

 

#6 2010-10-05 21:45:27

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: A problem with vertical scrolling

subzerostig wrote:

I think you only need 1 if,else block.
Think about it if its at the top then the block which knows it is at the top will hide it but then then the other if,else block will show it as it isn't at the bottom
Try this code:

<when green flag clicked>
<forever>
<if<<<( <y position> <>>150 )>  <or><(<y position>  <<> 50 )>  >>>
<show>
<else>
<hide>
<end>

Hope it helps.  big_smile

correction:
<forever>
<if<<<( <abs<y position> <>> 150>)
<show>
<else>
<hide>

Last edited by bbbeb (2010-10-05 21:45:48)


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

Board footer