I have a problem when scene change, please help

Hello,

I have a scene with 3 buttons.

When I went to the next scene and accidentally touched screen where one of the buttons on the previous one was scene the button from the previous scene is activated and opens an unwanted and unforeseen scene.

Even if you find it silly my question, please help because I can’t handle it myself.

Thanks for understanding and excuse me for my bad English.

You need to prevent such buttons from being touched again once a scene transition begins.

The simplest way to achieve this is to add an invisible rectangle on top of all other display groups that will capture all touch and tap events. When the scene transition begins, i.e. one of the buttons is pressed, you’d simply set .isHitTestable to true. Another approach is disabling any buttons that might cause issues during scene transitions. If you are using Corona’s widget buttons, then you could alternatively use https://docs.coronalabs.com/api/type/ButtonWidget/setEnabled.html

image.png

Create a new project.
And choose this tamplate.

You will learn from him to solve your problem.

Thanks for the tip XeduR @Spyric, I use widget buttons and this works great for me. Following your advice on hiding the scene, I turn off all the buttons and the application works perfectly. Once again thank you.

This is the best answer for me.

Invisible rect is by far the best way to block UX on scene transitions.  You can even extend storyboard/composer API to include this.  Then you just call *.blockUI() and *.enableUI() when needed.

I’ve actually been looking into the Composer framework quite a bit and it seems that there already is an invisible rect built-in that blocks touches and taps, but it is positioned incorrectly and it is using incorrect width and height values so it doesn’t actually block all touches if the actual device’s display is wider or taller than the one defined in config.lua

Thanks for the tip XeduR @Spyric, I use widget buttons and this works great for me. Following your advice on hiding the scene, I turn off all the buttons and the application works perfectly. Once again thank you.

This is the best answer for me.

Invisible rect is by far the best way to block UX on scene transitions.  You can even extend storyboard/composer API to include this.  Then you just call *.blockUI() and *.enableUI() when needed.

I’ve actually been looking into the Composer framework quite a bit and it seems that there already is an invisible rect built-in that blocks touches and taps, but it is positioned incorrectly and it is using incorrect width and height values so it doesn’t actually block all touches if the actual device’s display is wider or taller than the one defined in config.lua