When an object is tapped, how do I make the score go up in another scene?

Is it possible to tap an object from one scene and make a score go up in another

5 Likes

You can use a variable created in the Game section. It will be the same across all scenes.

Then when you increase it in one scene, it will also increase in the other scenes.

You can read more about the different types of variables in Hopscotch here, including game variables:

I’m just going to split these out into topics in #debug-my-code so that others can learn from them too! These are really valuable questions.

4 Likes

I just want to know if there’s an answer to my question

4 Likes

Unfortunately, doing things across scenes is not possible, as the inactive scenes are initially not loaded which is why you get that white flash when switching scenes, and they are also paused (including its code) when not in use.

However, you can prime the score update system with a variable, then on game start in the next scene, broadcast a message that auto updates the score by adding the new value, then reset the value of the new variable.

5 Likes

Idk how broadcast works

5 Likes

I figured out broadcast but how do I do the thing you said

4 Likes

Is anyone going to answer

4 Likes

No.

Have the scene with the object that is tapped increase the score variable. If that doesn’t work, have it increase its own score variable and when the scene with the score is displayed, add the two and reset the tapped variable.

11 Likes

Ok but why did you make the words get small

5 Likes

because my ipad is glitching.

7 Likes

you’ve done that twice [1] now (from what I’ve seen)


  1. maybe thrice ↩︎

7 Likes

If you start a “when game starts” code in one scene it won’t save to another, because the editor treats “when game starts” like “when scene starts”. And scenes are separate and don’t really connect besides the change scene block, so no code like that can work between scenes. If that’s what your asking.

3 Likes