How do we create a code so that when the player touches a red or green colored space, the “earnings” (text box) increase or decrease?
This CoSpaces is created like a board game, so when the player touches any green space, the text that says “earnings” would increase by 10. Alternatively, if the player touches any red space, the text would decrease by 10.
I think it may have something to do with creating Parent/ Child of all green spaces/ red spaces but I’m not totally sure.
How can we make something happen when the player (Camera) touches (collides) a type of square?
How can we make the earnings increase or decrease?
The 1st problem can be solved using the advanced collision CoBlock, and through checking the name of the Item collided to see if it is a red or green square (make sure all red squares have the same name - same for green).
The 2nd is fairly easy; see the following remixable space - it should give some clues as to how to update a variable & text:
I think there is another issue which your student will encounter, as they realise that they need to cross several red/green squares to get to their destination square - but cross that bridge when you get to it!
Hope that helps! Let me know if you have any further questions about this.
Thanks so much for your help! Yes, agree that an advanced collision block will need to be used. I was trying to find a way for students to avoid adding a collision for EACH green space/ red space-- maybe more concise code?
I tried renaming multiple green spaces with the same naming convention, but that didn’t help.
Here’s what I was playing with so far, (the Earnings text would change by 10 as the camera collides with a Greensquare):