My students want to do this: When they collect all 5 diamonds in one scene, they automatically go to the next scene. How do we code this?
Hi @Kelly_Nickell,
The easiest way is to create a variable with the taken diamonds count and for every diamond create onClick event. In that event you have to delete the current diamond from scene, increase the taken diamonds count (or decrease the number of diamonds to take) and check if all the diamonds are collected.
That handler for the diamond can be put into the function:
I have created a demo scene, you can remix it to see details
Can you please explain to me the first block? It is the read âaddDiamondâ block. WHere is this block?
addDiamond is a function. It is declared above the âWhen play clickedâ section.
In the âWhen Play clickedâ section this function is called for every diamond. And the body of the function is executed 5 times.
Hereâs a tutorial that should help you better understand functions in CoBlocks!
âŚ
I hope this will help you!