im trying to use variables to change backgrounds on my game, but it will not work. here's the sample code. this is for an assignment i'm doing.
[scratchblocks]
set [background v] to 0
if <(background) = 0>
switch to background [background5 v]
if <(background) = 1>
switch to background [background6 v]
when [right arrow v] key pressed
change [background v] by [1]
when [left arrow v] key pressed
change [background v] by [-1]
remember, i need to use variables, so i can include effects into it, and it can change into a main background, or a play area. in the play area, it cannot go back to the instructional pages.
Offline
srry
set [background v] to 0 if <(background) = 0> switch to background [background5 v] if <(background) = 1> switch to background [background6 v] when [right arrow v] key pressed change [background v] by [1] when [left arrow v] key pressed change [background v] by [-1]
Offline
kavinda wrote:
srry
set [background v] to (0) if <(background) = (0)> switch to background [background5 v] if <(background) = (1)> switch to background [background6 v] end end when [right arrow v] key pressed change [background v] by [1] set [background v] to ((background) mod (2)) filler//Or whatever number of backgrounds you have. when [left arrow v] key pressed change [background v] by [-1] set [background v] to (([abs v] of (background)) mod (2)) Filler//Same here.
I fixed and edited you're scripts.
Last edited by ErnieParke (2012-10-11 19:57:32)
Offline
ErnieParke wrote:
kavinda wrote:
srry
set [background v] to (0) if <(background) = (0)> switch to background [background5 v] if <(background) = (1)> switch to background [background6 v] end end when [right arrow v] key pressed change [background v] by [1] set [background v] to ((background) mod (2)) filler//Or whatever number of backgrounds you have. when [left arrow v] key pressed change [background v] by [-1] set [background v] to (([abs v] of (background)) mod (2)) Filler//Same here.I fixed and edited you're scripts.
thanks, ErnieParke! i really appreciate it!
Offline
ErnieParke wrote:
kavinda wrote:
srry
set [background v] to (0) if <(background) = (0)> switch to background [background5 v] if <(background) = (1)> switch to background [background6 v] end end when [right arrow v] key pressed change [background v] by [1] set [background v] to ((background) mod (2)) filler//Or whatever number of backgrounds you have. when [left arrow v] key pressed change [background v] by [-1] set [background v] to (([abs v] of (background)) mod (2)) Filler//Same here.I fixed and edited you're scripts.
what do you put in the filler?
Offline
kavinda wrote:
ErnieParke wrote:
kavinda wrote:
srry
set [background v] to (0) if <(background) = (0)> switch to background [background5 v] if <(background) = (1)> switch to background [background6 v] end end when [right arrow v] key pressed change [background v] by [1] set [background v] to ((background) mod (2)) filler//Or whatever number of backgrounds you have. when [left arrow v] key pressed change [background v] by [-1] set [background v] to (([abs v] of (background)) mod (2)) Filler//Same here.I fixed and edited you're scripts.
what do you put in the filler?
That's only there for me to put comments on, so ignore them. And your welcome!
Last edited by ErnieParke (2012-10-11 21:17:28)
Offline