I have a problem when exporting my game to HTML5. Changing scene doesn’t work in iPhone/Safari. It restarts the current scene instead of loading the “EndScene”. The game works fine in preview and in my computers web browser but not on my iPhone.
Here is a published test of the game:
Here is my code:
So I’m a bit stumped on this one. While it shouldn’t matter, try moving “Change to Scene” to the bottom of your action list (underneath the “Play the sound” action).
Events happen in order, and then actions happen in order. With how you’ve got it set up now, it may be running into conflict as it’s trying to change scene while other actions are being called.
Scene changing actions are special. Instead of directly Modifying the scene state it sets a flag containing the modification (pause scene, resume scene, unload scene etc) and after the events have been run it checks for the flag and if it is activated it applies the changes.
I have kinda solved it. The problem wasn’t in the current scene, it was in the scene that I jumped to. So what it did was to directly jump to another scene. But I don’t know why. Here is the code from the other scene. What I have tried to do is two buttons to either play again or finnis the game and get feedback.
Aah, okay. I think what’s happening is your mouse cursor/touch is ending up on the same spot as the new button in the new scene. This means it’s immediately activating the button once you switch to the scene.
I have similar issues when navigating the options menu in the game I’m working on. If I press the button/key it’ll rapidly go back to the other menu then switch back.
Here’s how I solved it:
- Create a global variable. I named mine MenuPress
- On your events that change scenes, make the first action Modify the value of a global variable and set MenuPress to 1
- Set a condition in ALL of your scene switching events of Value of Global Variable MenuPress = 0
- Set up a new event that checks for Touch or Left mouse button is down (invert), with an action of MenuPress = 0
This means that when you switch scenes, you cannot switch scenes again until you release the button/stop touching the screen. Should stop the rapid switching.
I have implemented your solution and will test it in my next build.