Discuss Scratch

Cheetaiean
New Scratcher
9 posts

Cannot rebroadcast

I have a game, when everytime I broadcast “change”, my variable ‘level’ is changed by 1.

When this happens the first time, as you see on the pic, the background is changed to Part 2. However, the next time the code will not broadcast, even though the broadcast condition (position of y-sprite=160) is met on this new background.

Any help would be greatly appreciated…

http://i.imgur.com/HExTcKU.jpg

(image system seems to be messed up so I just gave the direct link)






DotDash
Scratcher
1000+ posts

Cannot rebroadcast

Cheetaiean wrote:

I have a game, when everytime I broadcast “change”, my variable ‘level’ is changed by 1.

When this happens the first time, as you see on the pic, the background is changed to Part 2. However, the next time the code will not broadcast, even though the broadcast condition (position of y-sprite=160) is met on this new background.

Any help would be greatly appreciated…

http://i.imgur.com/HExTcKU.jpg

(image system seems to be messed up so I just gave the direct link)






The reason is because imgur is not allowed, it has inappropriate stuff on it.
scubajerry
Scratcher
1000+ posts

Cannot rebroadcast

I think the problem is when x = 160, CHANGE is continuously broadcast. When this happens, the CHANGE script is interrupted and restarted with each broadcast. To prove this, put a wait 5 seconds in your forever loop.
Cheetaiean
New Scratcher
9 posts

Cannot rebroadcast

put “wait 5 seconds” after the if statement but inside the forever. No change. It seems like the broadcast will only work once or something, the first time the if is met.
scubajerry
Scratcher
1000+ posts

Cannot rebroadcast

Can you share your project?
drmcw
Scratcher
1000+ posts

Cannot rebroadcast

Should really be in Help with scripts.

Using Broadcast and Wait will probably solve your problem, however you really should put all the when I receive change in one script instead of 3 to get rid of all the waits. You'll also need to move sprite 2 after the broadcast so it doesn't keep re-broadcasting.

Last edited by drmcw (Sept. 20, 2013 05:53:13)

Cheetaiean
New Scratcher
9 posts

Cannot rebroadcast

Doesn't necessarily have to be anything with broadcasting, I just want to change backgrounds when my sprite reaches a specific point or colour. So far no luck.

I have Scratch 1.4 btw.

Last edited by Cheetaiean (Sept. 20, 2013 12:49:21)

scubajerry
Scratcher
1000+ posts

Cannot rebroadcast

Can you upload your project and share it. I am sure it is something simple. You should try the broadcast and wait.
Cheetaiean
New Scratcher
9 posts

Cannot rebroadcast

http://i.imgur.com/CM6n5pe.png


Made it work somehow by rearranging script. Thanks for all your advice to put it into one thread and stuff. Also, scubajerry, I used the broadcast and wait command. This screenshot is the sprite page.

http://i.imgur.com/F2DKdQ2.png

The above is a pic of the stage page.

(Can't share because I am on a school computer and have no idea how….)

Last edited by Cheetaiean (Sept. 20, 2013 13:05:36)

drmcw
Scratcher
1000+ posts

Cannot rebroadcast

Cheetaiean wrote:

http://i.imgur.com/CM6n5pe.png


Made it work somehow by rearranging script. Thanks for all your advice to put it into one thread and stuff. Also, scubajerry, I used the broadcast and wait command. This screenshot is the sprite page.

http://i.imgur.com/F2DKdQ2.png

The above is a pic of the stage page.

(Can't share because I am on a school computer and have no idea how….)

We mean
broadcast [change v] and wait

not

broadcast [change v]
when I receive [change v]
wait (1) secs

Powered by DjangoBB