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

#1 2012-10-10 19:45:08

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

help with sprite program!

hey guys, since this is my first post, and im a newbie, i need help with one of my scripts. so the thing is that im trying to change backgrounds by using the left/right arrows, and by using variables by doing so. heres a part of the code

when [right arrow v] key pressed
change [background v] by [1]
if <(background) = [0]>
   switch to background [background2 v]
end
if <(background) = [1]>
   switch to background [background4 v]
end
if <(background) = [2]>
   switch to background [background5 v]
end

when [left arrow v] key pressed
change [background v] by [-1]
the problem is that when i try going back a page, it will remain on the current page, unless you press left twice, and right arrow once. please i really need help on this one!!!

Offline

 

#2 2012-10-10 21:20:50

gfchll
Scratcher
Registered: 2012-04-21
Posts: 100+

Re: help with sprite program!

to make things alot simpler

 when [right arrow v] key pressed
next costume

when [left arrow v] key pressed
switch to costume((costume #) - (1))

Last edited by gfchll (2012-10-10 21:21:12)


HELLO EVERYBODY!

Offline

 

#3 2012-10-10 21:37:47

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: help with sprite program!

Here's the problem with your original script: the "update background image" section of the script ("if background = 0, switch to background2, etc.") only is under your "right arrow" hat, so it never even gets called when you press the left arrow.  The variable updates, but not the image.  I would use gfchll's script, posted above.  It'll work fine.

Offline

 

#4 2012-10-11 09:09:05

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

Re: help with sprite program!

but do i do that with the background blocks, but not the costume blocks? after all, im doing it under the "stage"

Offline

 

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

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

Re: help with sprite program!

never mind, it worked, thanks

Offline

 

#6 2012-10-11 09:20:37

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

Re: help with sprite program!

new problem, i realized that i want a background to flash from one background to another, creating an effect, so i have to use variables. so its like a have a beginning page, that flashes "press right arrow to begin", and that works by switching from two backgrounds. can somebody help me out?

Offline

 

#7 2012-10-13 22:20:31

awesomeness321
Scratcher
Registered: 2012-08-10
Posts: 100+

Re: help with sprite program!

kavinda wrote:

new problem, i realized that i want a background to flash from one background to another, creating an effect, so i have to use variables. so its like a have a beginning page, that flashes "press right arrow to begin", and that works by switching from two backgrounds. can somebody help me out?

If I understand your problem, I think you can try this:

when gf clicked
repeat until <key [right arrow v] pressed?>
switch to background [press right arrow1 v]
wait (whatever amount of time you want between flashes) secs
switch to background [press right arrow2 v] 
wait (whatever amount of time you want between flashes) secs
end
switch to background [background after the 'press right arrow2' background v]
And use the other scripts people have given you as well. Make sure to just ADD this script, not REPLACE the other suggestions.
So use that script AND the
when [right arrow v] key pressed
next background
when [left arrow v] key pressed
switch to background ((background #)-(1))
Or make the flashing words a separate sprite.

Last edited by awesomeness321 (2012-10-13 22:20:49)


My newest project:http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=projects&amp;type=newest&amp;return=image&amp;num=1Color:#30F9A5 I am currently http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=onlineStatus&amp;type=text

Offline

 

Board footer