Very generally speaking, as your question is very general… and the correct answer really depends on exactly what your app does, and so forth; but, in general (for a simple app), I normally have in my ‘gameScene’, which is the scene where most all of the game play occurs, a gameLoop function. But, you can put it in any scene and name your scene anything you want. I put it in the ‘scene:show( event )’ function.
function scene:show( e ) if ( e.phase == "will" ) then elseif ( e.phase == "did" ) then local function gameLoop(e) -- do most of your endless runner code here, each frame end Runtime:addEventListener("enterFrame", gameLoop) end end
That is for a simple quick way of doing it. Often, the actual gameLoop function I will place outside of the composer functions, up near the top of my code.(it just seems cleaner to me)… but it will work either way. Remember to remove the ‘enterFrame’ event listener when leaving the scene.
You will need to spend a fair amount of time going over some of the example composer apps that some of the other developers have on the forum… and then play around with them by changing things(experimenting) … that is the only way to really learn it and get a feel for it all. It is time consuming and takes some effort.
Again, this is very general. Normally, I setup must the variables and such in the scene:create, and handle most of the movement, loops, flag checking, and action in the scene:show
Good luck.