If you wanted a scroller, just use the wiki:http://wiki.scratch.mit.edu/wiki/Scrolling
If you want a normal movement with background changes then you use this script:
when gf clicked //player sprite forever if (x position) < [245] broadcast [right v] end if (x position > [-245] // these values may need tuning broadcast [left v] end when gf clicked // put this in the stage delete [all v] of [rightlist v] delete [all v] of [leftlist v] set (backgroundcounter) to 0 set (leftcounter) to 0 set (rightcounter) to 0 add (rightbackground1) to [rightlist v] add (rightbackground2) to [rightlist v] // as many backgrounds to the right as you have add (leftbackground1) to [leftlist v] add (leftbackground2) to [leftlist v] // as many backgrounds to the left as you have when I receive [right v] change [backgroundcounter v] by [1] change [rightcounter v] by [1] change [leftcounter v] by [-1] if (backgroundcounter) < 1 switch to background item (leftcounter) of [leftlist v] else switch to background item (rightcounter) of [rightlist v] when I receive [left v] change [backgroundcounter v] by [-1] change [rightcounter v] by [-1] change [leftcounter v] by [1] if (backgroundcounter) < 1 switch to background item (leftcounter) of [leftlist v] else switch to background item (rightcounter) of [rightlist v]I have NO idea if this'll work, I came up with it on the spot but it should work. Code order might need a bit of tweaking
Offline
zammer990 wrote:
EDIT
mostly fixed scratch blockswhen gf clicked //player sprite forever if (x position) < [245] broadcast [right v] if (x position) > [-245] // these values may need tuning broadcast [left v] end when gf clicked // put this in the stage delete [all v] of [rightlist v] delete [all v] of [leftlist v] set (backgroundcounter) to 0 set (leftcounter) to 0 set (rightcounter) to 0 add (rightbackground1) to [rightlist v] add (rightbackground2) to [rightlist v] // as many backgrounds to the right as you have add (leftbackground1) to [leftlist v] add (leftbackground2) to [leftlist v] // as many backgrounds to the left as you have when I receive [right v] change [backgroundcounter v] by [1] change [rightcounter v] by [1] change [leftcounter v] by [-1] if (backgroundcounter) < [1] switch to background item (leftcounter) of [leftlist v] else switch to background item (rightcounter) of [rightlist v] when I receive [left v] change [backgroundcounter v] by [-1] change [rightcounter v] by [-1] change [leftcounter v] by [1] if (backgroundcounter) < [1] switch to background item (leftcounter) of [leftlist v] else switch to background item (rightcounter) of [rightlist v]I have NO idea if this'll work, I came up with it on the spot but it should work. Code order might need a bit of tweaking
Offline
Wow zammer990, i don't think it needs to be that complicated!
if <<<(x position) > [240]> or <(x position) < [-240]>> or <<(y position) > [180]> or <(y position) < [-180]>>> broadcast [change background v] end when i receive [change background v] //in the Stage switch to background [other background v]
Offline
scimonster wrote:
Wow zammer990, i don't think it needs to be that complicated!
if <<<(x position) > [240]> or <(x position) < [-240]>> or <<(y position) > [180]> or <(y position) < [-180]>>> broadcast [change background v] end when i receive [change background v] //in the Stage switch to background [other background v]
My way was a bit of a bizzare way of doing it I know
Your way would only work assuming you only wanted to have it change backgrounds in one long line, for example if you went left right left right left you would just change to background 2,3,4,5,6
My code makes it multidirectional, going left then right would take you back to costume 1
Offline
Or how about this:
forever if<touching [edge v]?> broadcast [change background v] wait until <not <touching [edge v]?>> // optional end
Last edited by MoreGamesNow (2012-05-02 11:20:59)
Offline