Unit testing a game with physics

I am unit testing my game. So in my test I instantiate my code, but I have
no way of advancing the game ahead by a frame. I tried
Runtime:dispatchEvent(‘enterFrame’); to no avail.

So I need to tell Corona to advance my game by a frame, more specifically I
need the physics engine to advance a frame.

ie:
for i=1, 100 do MAKE PHYSICS ENGINE APPLY GRAVITY AND DO OTHER THE OTHER
THINGS IT MIGHT DO EACH FRAME; end
[import]uid: 162900 topic_id: 30864 reply_id: 330864[/import]

Hi Jacob,
There isn’t a direct way to run an app frame by frame, but you might be able to control the physics engine in a similar way by pausing it, then starting a repeating timer that, when it triggers, it resumes the physics engine for just one frame then pauses it on the next frame. You’d need to set up a Runtime listener that manages the toggle state via a boolean variable, such that, on a particular frame step it detects if the physics is paused or not. If it is, it resumes it and toggles the boolean. Then on the next frame step, it knows the state is different, so it pauses the physics and toggles the boolean back. Repeat this process via the timer, and it might “simulate” a frame by frame physics environment.

Brent Sorrentino [import]uid: 9747 topic_id: 30864 reply_id: 123495[/import]

Hi Jacob,
There isn’t a direct way to run an app frame by frame, but you might be able to control the physics engine in a similar way by pausing it, then starting a repeating timer that, when it triggers, it resumes the physics engine for just one frame then pauses it on the next frame. You’d need to set up a Runtime listener that manages the toggle state via a boolean variable, such that, on a particular frame step it detects if the physics is paused or not. If it is, it resumes it and toggles the boolean. Then on the next frame step, it knows the state is different, so it pauses the physics and toggles the boolean back. Repeat this process via the timer, and it might “simulate” a frame by frame physics environment.

Brent Sorrentino [import]uid: 9747 topic_id: 30864 reply_id: 123495[/import]