Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

A question of physics..
Started by tom03 Mar 03 2019 10:00 PM

2 replies to this topic
physics modules newbie
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tom03

[GLOBAL: userInfoPane.html]
tom03
  • Observer

  • 7 posts
  • Corona SDK

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

 



[TOPIC: post.html]
#2

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,059 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

tom03

[GLOBAL: userInfoPane.html]
tom03
  • Observer

  • 7 posts
  • Corona SDK

ok cool, thanks.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: physics, modules, newbie