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

#1 2012-10-11 19:27:34

kavinda
New Scratcher
Registered: 2012-10-09
Posts: 9

another problem! really need help

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

 

#2 2012-10-11 19:31:58

kavinda
New Scratcher
Registered: 2012-10-09
Posts: 9

Re: another problem! really need help

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

 

#3 2012-10-11 19:56:01

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: another problem! really need help

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2012-10-11 20:05:31

kavinda
New Scratcher
Registered: 2012-10-09
Posts: 9

Re: another problem! really need help

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

 

#5 2012-10-11 20:12:14

kavinda
New Scratcher
Registered: 2012-10-09
Posts: 9

Re: another problem! really need help

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

 

#6 2012-10-11 21:16:44

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: another problem! really need help

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer