I have mainmenu scene and a game scene. The main menu has two buttons: play and select character. When the user clicks play and the game opens, the game runs fine. But when the user taps the area where the buttons were in the main menu, they still function although not visible. It restarts the game if you tap the area where the play game button used to be and goes to the character select scene when the area of the character select button is tapped.
You either didn’t add the buttons to the scene or you made a mistake when doing so.
In either case, the buttons will now be behind the new (incoming) scene, and still be press-able.
I have a ton of examples showing how to make scenes with interfaces and other features:
https://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/composer_scene_manager.zip
Examples Index:
- 1_transitions - Examines basic transitions and allows you to try all of the known transition.
- 2_eventSequence - Dumps scene transition phases to console so you can understand when they happen and how they relate to transitions.
- 3_badManagement - Shows example of ‘bad’ (or incorrect) object management.
- 4_goodManagement - Same as ‘4’ with corrections to properly handle management.
- 5_frame - Basic app framework using Composer.
- 6_memory - Shows memory usage examples.
- 7_custom_transitions - Shows custom transitions and how to make them.
- 8_objectsInModules - Shows how to manage sprites and other modules in coordination w/ Composer.
- 9_simple_organization - Examples of how to organize data so it can easily be accessed across scene scopes.
- 10_change_scene_on_collision - Answer to forums question, “How can I change scenes when an object in my scene collides with another object?”
- 11_reference_passing - Answer to a forums question, “How do I pass data from one scene to another?”
- 12_rebuild_playgui - Example of ‘building the scene on each re-entry’ versus just once in ‘create’.
- 13_textFields - Answer to question in forums, “How do I manage my text fields between scenes?”
- 14_textFields_as_scene_gates - Changes last example to prevent scene changes unless specific values are in the text fields.
take a peek and see what i’ve done.
@roamminggamer
As always Ed, your helpful and well thought out approaches to problems are good for newish and seasoned developers alike
How do I fix it? I didn’t really understand what you sent.
Did you download my examples and look at them? Specifically the framework (#5)?
The solution is pretty straight forward. Put your buttons in the scene group of the main menu scene.
I don’t know what button code you’re using, but I assume it is the widget.* library. So read these docs:
Widget Buttons:
https://docs.coronalabs.com/api/library/widget/newButton.html
Composer: https://docs.coronalabs.com/api/library/composer/index.html
Read this entire page: https://docs.coronalabs.com/guide/system/composer/index.html
Again, I have no idea what you’re doing, but my best guess is you have some code like this:
function scene:create( event ) local sceneGroup = self.view -- Create the widget local button1 = widget.newButton( { left = 100, top = 200, id = "button1", label = "Default", onEvent = handleButtonEvent } ) -- YOU PROBABLY DIDN'T DO THIS: sceneGroup:insert(button1) end
Once you read the docs and if you still can’t figure it out, then…
Zip up your project. Share it here (using the ‘more reply options’ button below) and someone will probably take a look and give you feedback.
Note: I think the thing you may not be understanding is that each ‘scene’ has a display group it manages. If you want your ‘content’ (buttons, etc.) to be managed by the scene, you need to put them in that scene’s display group.
My examples demonstrate this and a lot of other things.
Don’t forget, Corona comes with a ton of examples too. You can access them from the simulator dialog that comes up when you start the simulator. I’m sure there must be widget and composer examples in there.
You either didn’t add the buttons to the scene or you made a mistake when doing so.
In either case, the buttons will now be behind the new (incoming) scene, and still be press-able.
I have a ton of examples showing how to make scenes with interfaces and other features:
https://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/composer_scene_manager.zip
Examples Index:
- 1_transitions - Examines basic transitions and allows you to try all of the known transition.
- 2_eventSequence - Dumps scene transition phases to console so you can understand when they happen and how they relate to transitions.
- 3_badManagement - Shows example of ‘bad’ (or incorrect) object management.
- 4_goodManagement - Same as ‘4’ with corrections to properly handle management.
- 5_frame - Basic app framework using Composer.
- 6_memory - Shows memory usage examples.
- 7_custom_transitions - Shows custom transitions and how to make them.
- 8_objectsInModules - Shows how to manage sprites and other modules in coordination w/ Composer.
- 9_simple_organization - Examples of how to organize data so it can easily be accessed across scene scopes.
- 10_change_scene_on_collision - Answer to forums question, “How can I change scenes when an object in my scene collides with another object?”
- 11_reference_passing - Answer to a forums question, “How do I pass data from one scene to another?”
- 12_rebuild_playgui - Example of ‘building the scene on each re-entry’ versus just once in ‘create’.
- 13_textFields - Answer to question in forums, “How do I manage my text fields between scenes?”
- 14_textFields_as_scene_gates - Changes last example to prevent scene changes unless specific values are in the text fields.
take a peek and see what i’ve done.
@roamminggamer
As always Ed, your helpful and well thought out approaches to problems are good for newish and seasoned developers alike
How do I fix it? I didn’t really understand what you sent.
Did you download my examples and look at them? Specifically the framework (#5)?
The solution is pretty straight forward. Put your buttons in the scene group of the main menu scene.
I don’t know what button code you’re using, but I assume it is the widget.* library. So read these docs:
Widget Buttons:
https://docs.coronalabs.com/api/library/widget/newButton.html
Composer: https://docs.coronalabs.com/api/library/composer/index.html
Read this entire page: https://docs.coronalabs.com/guide/system/composer/index.html
Again, I have no idea what you’re doing, but my best guess is you have some code like this:
function scene:create( event ) local sceneGroup = self.view -- Create the widget local button1 = widget.newButton( { left = 100, top = 200, id = "button1", label = "Default", onEvent = handleButtonEvent } ) -- YOU PROBABLY DIDN'T DO THIS: sceneGroup:insert(button1) end
Once you read the docs and if you still can’t figure it out, then…
Zip up your project. Share it here (using the ‘more reply options’ button below) and someone will probably take a look and give you feedback.
Note: I think the thing you may not be understanding is that each ‘scene’ has a display group it manages. If you want your ‘content’ (buttons, etc.) to be managed by the scene, you need to put them in that scene’s display group.
My examples demonstrate this and a lot of other things.
Don’t forget, Corona comes with a ton of examples too. You can access them from the simulator dialog that comes up when you start the simulator. I’m sure there must be widget and composer examples in there.