Hi Rob, thanks for your help with this, as in physics.stop() on exitscene? I was using storyboard.purgeAll( )
storyboard.removeAll( ) but didn’t work either?
Hi Rob, thanks for your help with this, as in physics.stop() on exitscene? I was using storyboard.purgeAll( )
storyboard.removeAll( ) but didn’t work either?
Yes, as in physics.stop() in the exitScene handler. Physics isn’t managed by storyboard, just the display objects so even if you purge or remove the scene, the physics engine still has the physics bodies in the physics engine and they are still interacting. Collisions will still process and if the code to handle the collisions isn’t in memory (i.e, removeScene()) then it will generate a signal 11 SIGSEGV or Segment Violation and your app blows up and dies.
Stop the physics, and make sure to remove the collision handler events.
Rob
Ok Rob, I’ll give that a go.
Again many thanks for your help on this.
Regards
Anthony
Still lost, no idea whats happening, physics.stop() not working and going back to menu with all game graphics still on screen?
From what I’ve seen of your code and the issues you’re describing, you may have some Runtime loop that is crashing your simulator. You might not like this suggestion, but at this point you might want to start small by removing everything in your scene, and add back items slowly, making sure your code works correctly. It appears that would be the best way to debug your issue at this point.
Thanks for the feedback appreciate it, not liking storyboard.
The Ricardo Rauber-developed Director is a useful alternative, but you’re still going to run into the same kinds of issues: making sure that all display objects and runtime listeners are removed when a scene is left.
To be honest I’m kinda giving up, storyboard is a nightmare, and I’m finding it very disheartening.
I really appreciate your help tho thank you.
I’m sorry to hear that. Is it Storyboard specifically that is giving you a headache? Can you describe what you are attempting to accomplish? Maybe I can help you identify a better way of getting to your end goal.
I have, a menu.lua / levels.lua (with back button to menu, and working) / about.lua (with back button to menu, and working) and a game.lua file code is running and game working, I just cannot find out what is happening on the goto any other .lua file from the game?
It seems to be not destroying the scene fully? I’m doing something wrong and cannot see it?
OK, #1 I see you’ve got a bunch of runtime listeners in the game module. Are you absolutely sure these are being removed when you change scenes? Are you getting any errors in the console when testing the scene change?
If everything else is working as normal, I’d suggest taking everything out of the game module, and slowly and methodically add back in your game objects. Then add in the listeners.
I was getting some third party error, but couldn’t find anything about it? the scrolling background is removing itself, but everything else is staying?
I’m finding it difficult to understand the structure of adding display objects and removing them? ie sprites etc?
Ok, a few things:
That’s just what I’ve seen in a cursory glance. Let me know if that helps, or if you need some additional tips.
Let me add a few more thoughts to this.
First, Director has always been a popular product, but it has been a long time since it was updated and the Graphics 2.0 engine has changes that Director isn’t happy about. It should work in v1 compatibility mode, but for the long term, unless Ricardo updates, or someone else takes over updating it, it’s only going to become more problematic. I loved Director and have several apps that use it.
Storyboard works and it works well. You just have to understand how Lua modules work and how events work. And then the tough part, you have to understand the order that storyboard events fire. It’s really not that hard, but there is a learning curve. Once you get past that, Storyboard is really easy to work with.
Looking at your code (though it’s probably not the latest), and as PaNc has mentioned already:
You do:
local screenGroup = self.view
This is the storyboard group. Any display objects NOT inserted into that group, will not be managed by Storyboard and will stay on the screen when you change scenes.
A couple of lines down you do:
group = display.newGroup() (I forget if you made it local or not).
You do insert things into “group”, but not screenGroup. You could insert group into sceenGroup (i.e. screenGroup:insert(group) ) to solve that, but I don’t think you intend to do this, but instead got confused because some people use “group” and others use “screenGroup”…
Then you have a bunch of display objects and sprites that are not getting inserted into anything. Storyboard cannot manage these.
Next, you should not call either purgeScene() or removeScene() (or purgeAll() or removeAll()) in the exitScene handler. The scene is still on the screen and you’re telling to delete what’s there. It can’t do this until after that scene is transitioned away and the new scene is in it’s place. Your best bet is to purge or remove the scene before you go to it. Optionally you can call them in the enterScene() of the scene you are going to if you know for certain where you are coming from. In other words, scene2 can purge/remove scene1 but scene2 cannot remove sceen2.
Purge and remove do the same thing but at the same time do different things. Both cause the destoryScene() function to run and then anything in the scene’s view (screenGroup in your case) to be removed from the display and freed up. RemoveScene() goes one step further and un-requires the module completely.
Neither of these removes any listener attatched to “Runtime” or the stage. Nor does it stop and cancel any timer, or transition. It does not stop or cancel any audio and it does not stop physics or remove phyisics bodies. You have to do all of that most likely best done in the exitScene. Think of it like this:
createScene: create display objects and sprites, potentially load any audio, but do not start playing it. start physics before adding bodies.
destroyScene: dispose of your audio.
enterScene: create any native object, start physics, start any transition, move any display object back to it’s origin (if reloading the scene), play any audio that needs started, start timers, etc.
exitScene: remove anything you created in enterScene, stop any thing you started.
Finally, you talked about getting errors from some 3rd party library. It’s really hard for us to help you if you don’t post the errors and the line number (and code) that’s causing it too.
Rob
Now to change directions here a bit…
Thanks so much for your help on this Guys. I think the problem I have as you correctly say, is the local screenGroup = self.view
I’ve inserted the backgrounds like so…in function scene:createScene( event )
local screenGroup = self.view
local background = display.newImage("images/final/background-1.png") screenGroup:insert(background) background1 = display.newImage("images/final/background-1.png") background1:setReferencePoint(display.BottomLeftReferencePoint) background1.x = 0 background1.y = 320 background1.speed = 0.1 screenGroup:insert(background1)
in the function scene:enterScene( event )
local group = self.view I’ve added
background1.enterFrame = scrollBackground Runtime:addEventListener("enterFrame", background1)
and in function scene:exitScene( event )
local group = self.view I’ve added
Runtime:removeEventListener("enterFrame", background1)
And this seems to be working fine, and removing the background, so is the logic the same for the remaining code?
1/ screenGroup:insert(background1) – scene:createScene( event ), to enter object into group
2/ Runtime:addEventListener(“enterFrame”, background1) --scene:enterScene( event )
3/ Runtime:removeEventListener(“enterFrame”, background1) --scene:exitScene( event )
i.e. for a sprite how would you screenGroup:insert(sprite) ?
Getting this as an error
termination requested by 3rd party … shutting down (signal 15)
logout
Can you post the log with a few lines before and after it. Do not edit out the timestamps or any other parts of the line. We need to try and track down that message. It doesn’t look like a message we would be generating.
Got to restart.lua now getting this? HEEEEELLLLLP
Corona Simulator[976:707] ERROR: physics.stop() cannot be called when the world is locked and in the middle of number crunching, such as during a collision event
2013-12-19 20:24:54.509 Corona Simulator[976:707] termination requested by 3rd party … shutting down (signal 15)
logout
Ok got to move from game to menu screen seemed to be an audio problem, but now physics all over the place when going from restart to menu again?