Question about enterFrame eventListener.

Hi guys,
Let’s say I have the following code :

local function animate(event)  
 --- do stuff in here  
end  
Runtime:addEventListener( "enterFrame", animate );  

And that my “do stuff in here” takes long time. Will the animate function still be called every 16ms ( many animate function in parallel ) or will the first animate function interrupted or will the second event only fired after the first animate function ( the long one ) is finished ?

Thanks a lot.
Bruno from http://blueglutton.com [import]uid: 9097 topic_id: 8064 reply_id: 308064[/import]

That’s an interesting question, why don’t you test it? My guess is that the second event will wait until the first one is finished, since the enterFrame event isn’t really based on a timer, it is based on when frames are rendered. [import]uid: 12108 topic_id: 8064 reply_id: 28941[/import]

I haven’t tested it because I am too lazy ( shame on me ) and I hoped someone would have already tested it. Having read some post about app animation freezing when enterFrame eventlistener takes too long I think your guess is right. Anyway I am going to test it when I have a few sec in my planning. My concern is that I don’t know how to choose between a timer based game or an enterFrame event based game to call my main function.

Bruno from http://blueglutton.com [import]uid: 9097 topic_id: 8064 reply_id: 28949[/import]

My concern is that I don’t know how to choose between a timer based game or an enterFrame event based game to call my main function.

Most single-player games should use enterFrame for the main loop but use the delta time technique to account for low framerates on crappy machines. There’s little point to timing the game independent of enterFrame since it’ll only be visible on enterFrame.

Now this logic changes for multiplayer games. Although I would still recommend enterFrame for most games, with multiplayer you do have the significant wrinkle of different framerates on different computers. Then there is a case to be made for calling the main loop on a timer. [import]uid: 12108 topic_id: 8064 reply_id: 28953[/import]