A question of physics..

Where is it best to put physics.start() ?

I have a composer project with a couple of scenes.

I have a module that creates a starfield - a background group of stars that travel across the screen - I’ve attached physics bodies to display objects and attributed a linear velocity within the stars.lua module. 

This module is the only module in my scene that uses physics so I have required physics in the stars.lua module and called physics.start() in the modules init() function.

I also call physics.stop() when the module is removed at the end of the scene.

So, my question is … is this okay? or should I require and manage the physics from my scene.lua file? I guess I would do this if other objects/modules required access to physics but in this instance they don’t.

Many thanks,

Tom

Start the physics engine at the start of your main.lua.

If you want physics paused, you can do that elsewhere, but always initialise and start at the beginning of your program - not other modules and definitely not with the chance where it might be initialised more than once.

ok cool, thanks.

Start the physics engine at the start of your main.lua.

If you want physics paused, you can do that elsewhere, but always initialise and start at the beginning of your program - not other modules and definitely not with the chance where it might be initialised more than once.

ok cool, thanks.