Howdy,
I’ve done a lot of searching on the forum but I still havent been able to find out the answer to this problem.
I am using storyboard and the physics engine. main.lua points to “level1” at which point i declare the physics library at the top before enterScene:
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local physics = require (“physics”)
physics.setDrawMode(“hybrid”)
physics.start()
physics.setGravity(0,0)
tileMap = require (“tiles”)
level = require (“levelData”)
enterScene starts here calling functions from within “tiles” and “leveldata”
I then go on to add functions, graphics, level data etc and everything in “level1” works fine, ie applying physics forces to a character to make them move about.
after a certain event occurs storyboard jumps out to “level2”. In exitScene I remove all event listeners and presumably the display groups are nilled upon exit via storyboard API. The next level data all loads correctly and i can see any objects I declare either prior to create Scene in level2 or within it.
The physics engine no longer works in this scene - even the hybrid or debug view is not active. I have tried several solutions - declaring physics and turning it on in main.lua as a global, i have copied and pasted exact same code into “level2.lua” as the code above but it refuses to work. I have tried stopping and starting the engine in various places throughout the storyboard scenes.
In one configuration when i push a button that worked in level 1 which would apply a physics force to my character i get the message: attempt to call method: set linearimpulse which is a nil value.
Now i guess I’m missing something fundamental in how storyboard treats physics or libraries in general but I cannot figure this one out. It also seems to crash the corona simulator which doesnt help!
I can post the code but i cant see it being relevant to this issue and there is a lot of it!
Any advice massively appreciated!
Thanks
Iain