I have seen users like AB3 and Wes64 use this, but I don't understand the mechanics. I know it has to do with stamping, but I don't know how to program it. Can someone help?
Thanks!
Offline
Okay, you're going to need a variable called xscroll for the scrolling amount. Then, you need to do this:
when gf clicked hide //The stamping will do all of the work. forever clear //Remove all previous stamps or pen marks. if <<key [left arrow v] pressed?> and <(scrollx) < (0)>> change [scrollx v] by (1) //You can change this to 2, 3, 4, or 6. end if <<key [right arrow v] pressed?> and <(scrollx) > (-480)>> //Limits scrolling to 480 pixels, or 2 backgrounds. change [scrollx v] by (-1) //The same as above, but negative. end switch to costume [costume1 v] //The first background. if <(scrollx) < [480]> //If the first background will be in the screen. go to x: (scrollx) y: (0) stamp end switch to costume [costume2 v] //The second background. if <(scrollx) > [0]> //If the second background will be in the screen. go to x: ((scrollx) + ((480) * (1))) y: (0) stamp end endThat's a very basic 2-background scroller. If you want it to be longer, I'll post a solution to that.
Offline
berberberber wrote:
Could you tell me how to extend it?
Okay!
You start with this:
when gf clicked hide forever clear if <<key [left arrow v] pressed?> and <(scrollx) < (0)>> change [scrollx v] by (1) //You can change this to 2, 3, 4, or 6. end if <<key [right arrow v] pressed?> and <(scrollx) < (960)>> //Set this number to ((your amount of backgrounds minus 1) times 480) change [scrollx v] by (-1) //The same as above, but negative. end endOkay, now, the first one's scripts:
switch to costume [costume1 v] //Your first background. if <(scrollx) < (-480)> go to x: (scrollx) y: (0) stamp endAdd that at the end of the forever loop.
switch to costume [costume2 v] //Set this to the correct one. if <<(scrollx) < (0)> and <(scrollx) > (-960)>> //Change these numbers by -480 for each background. go to x: ((scrollx) + ((480) * (1))) y: (0) //Change the 1 by 1 for each background. stamp endNo, finally, for the last one. Just add this to the end of the forever loop:
switch to costume [costume3 v] //Your last background. if <(scrollx) > (-480)> //Set this to (((amount of backgrounds minus 1) times 480) times -1) go to x: ((scrollx) + ((480) * (2))) y: (0) //Set the 2 to the amount of backgrounds - 1. stamp endAll done! I'm sorry if I didn't explain it well. I hope this helps!
Last edited by SciTecCf (2012-06-17 13:47:47)
Offline
If you want to extend it into infinite, you should use the "mod" block. Basically, the mod block gives you the remainder after dividing the first number by the second. You have to think about it a bit before it makes sense:
-you want 2 stamps/positions.
-each one must be able to travel from one side to the other and then loop around
next, get into the math:
-since each scene is a full screen (480 pixels long) and the screen is 480 pixels long, in order for it to completely exit the screen on both sides, it must travel from x=480 to x=-480
-480*2=960 is thus the number we will use for the modulus or mod block.
so far we have:
go to x: ((scrollx) mod (960)) y: (0)but this will make our sprite travel from 960 to 0 and then loop back to 960, so we have to make it:
go to x: (((scrollx) mod (960))-(480)) y: (0)instead.
go to x: ((((scrollx)+(480)) mod (960))-(480)) y: (0)should do the trick.
Last edited by AtomicBawm3 (2012-06-17 15:34:46)
Offline
berberberber wrote:
Thanks, but could you sho me the whole script, AB3?
Sure:
when gf clicked set [sx v] to (0) forever switch to costume go to x: (((((sx) * (-1)) + (480)) mod (960)) - (480)) y: (0) stamp switch to costume go to x: ((((sx)*(-1)) mod (960)) - (480)) y: (0) stampThis is what I used for Dark and Light.
Last edited by AtomicBawm3 (2012-06-17 16:38:29)
Offline
Is it something like this?
When gf clicked forever switch to [costume 1 v] go to x: (cos1 x) y: (cos1 y) stamp if <key [right arrow v] pressed change [cos1x v] by [1] end if <key [left arrow v] pressed change [cos1 y] by [-1] endAnd then you just do as many costumes and sensing scripts as you need?
Offline