ScratchData LogoScratchData
Back to kriblo_test's profile

Broadcast in a loop in a non-refresh block

KRkriblo_test•Created October 6, 2021
Broadcast in a loop in a non-refresh block
9
4
59 views
View on Scratch

Instructions

Code in broadcast handlers (called without wait) is run after the code in the calling hat-block or loop iteration is run. If the broadcast is issued several times in the calling code, it will still only be run once, after. Sprite1 and Sprite2 each enter a forever loop, each iteration executing consecutively. Each iteration in the main loop, they call their own "Move" custom block with no screen refresh. In that block, Sprite1 loops 4 times, each time moving 1 step to the right. When the screen refreshes, Sprite1 will have moved 4 steps. In its Move block, Sprite2 loops 4 times, each time broadcasting "Move" (without wait). The "Move" broadcast handler moves Sprite2 one step to the right. When the screen refreshes, Sprite2 will only have moved 1 step. See inside why. Also, see inside at the sprite "Another example" and press keys 1-4. All code by me (@kriblo).

Project Details

Project ID579994384
CreatedOctober 6, 2021
Last ModifiedOctober 6, 2021
SharedOctober 6, 2021
Visibilityvisible
CommentsAllowed