Corona app execution loop

I was wondering in what order the following take place in the Corona app execution loop:

  • touchEvents are dispatched handled
  • enterFrame events are dispatched handled
  • display is refreshed
  • physics objects are updated by physics engine
  • programmer defined events (if this is even possible. If so, how do you do this by the way? Question has been asked before but the thread died.)

  • Since I use the “enterframe” event to trigger my game update, it would be good to know whether my game code or my UI code runs first.

I havent found any documentation from Ansca that describes the execution loop at all. What else is going on behind the scenes that might be of interest to the coder, and in what order? Does anybody have a reference to some documentation?

Request: I’d really appreciate a write-up on this.

[import]uid: 48545 topic_id: 21104 reply_id: 321104[/import]

Hey there, we actually do have some docs on this although I know they’re a little hard to find; http://developer.anscamobile.com/content/application-programming-guide-graphics-and-drawing#Drawing_Cycle

Peach :slight_smile: [import]uid: 52491 topic_id: 21104 reply_id: 83511[/import]

Hi Peach.

I’ve looked through this doc before. However it pretty much only says “At the beginning of each cycle, an “enterFrame” event is dispatched to any registered listeners in your Lua code.” And that doesnt really say anything at all since it doesnt put the enterframe in relation to other phases that I mentioned above.
You see my point?

Micke d^) [import]uid: 48545 topic_id: 21104 reply_id: 83524[/import]

In Corona pretty much everything is tied to the frame rate (30 or 60 fps). All the event listeners, timers, physics, UI and display updates occurs at the enterFrame event. The one real exception is Audio, which occurs on it’s own thread.

Generally, the event loop occurs first followed by the display update.
[import]uid: 7559 topic_id: 21104 reply_id: 83683[/import]

The question still remains, in which order are these events handled/dispatched? It is important. It is also important to know whether the order is always the same. [import]uid: 48545 topic_id: 21104 reply_id: 83763[/import]

The information I provided should be all that you need. If your program needs to know the exact order of execution, there is something wrong with how it’s implemented or Corona is not the right solution for your app.

In the future, if we may need to change the internal implementation to improve performance or add new features, it could break any code that relies on these internal implementation details. [import]uid: 7559 topic_id: 21104 reply_id: 83798[/import]