Changing scenes glitches "when game starts" block

Use this template to make awesome bug reports:

Your username: GalaxyBoi

What kind of device are you using?: (Also include iOS version, and Hopscotch version)
iPhone X, iOS 15.2, v3.48.3

1 sentence description of the problem (I was doing _________, and then __________ happened):

I was playtesting my game when suddenly all the “when game starts” blocks break when I change scenes

Steps that the Hopscotch team can take to reproduce my problem every time:

  1. Create a game with multiple scenes
  2. Add elements that allows you to switch from one scene to another
  3. Keep pressing the buttons when testing the game
    ….

I expected this to happen:
Everything run smoothly
But instead this happened:
Glitched everything
Here’s a sweet screenshot video:
How to send vids (I’ll edit this part later)

4 Likes

You can use catbox.moe to upload videos and link them here.

Also, this is manly caused by clones, since the When Game Starts block executes whenever a scene changes, which means the clones will clone themselves again, which can get exponential due to each clone cloning themselves a large number of times each.

3 Likes

which?

you can do with Catbox.moe, or with youtube :)

2 Likes

@anon82626866

4 Likes

Oh, this is because you’re using the Grow By block. The objects retain their sizes when a scene changes, so they’ll just keep growing more and more. Use the Set Size % block instead.

3 Likes

yes @GalaxyBoi :arrow_up:

remember, when you’re using scene, When Game Starts rule is run each time the scene is switched. To prevent having a code run multiple time, you can add this code to each When game starts rule.

When Game Starts
If RunOnce = 0
Set RunOnce to 1
// Rest of your code
3 Likes

Thanks @anon82626866 @Crosbyman64

4 Likes

No problem. Me and NTh3R have seen this type of problem before when we’ve made projects with scenes. Especially while using clones.

4 Likes

Oh wait
So you can switch to previous scenes without it glitching then? (With Nth3r’s code)

3 Likes

There are lots of ways to sort out the issue:

  • disable the When Game Starts rules via variables (use 1 per scene)
  • use when (self total objects = 1) only works with clones
  • When self total clones < ## only clones to specified amount
  • when self clone index = 0 (to only apply to original object)
4 Likes

This topic was automatically closed after 4 days. New replies are no longer allowed.