Game loop design issues

This obviously isnt achieving what I thought it would, I want the gameLoop() function to run when the file is ‘required’ by another file. How is this normally done?

[lua]local function gameLoop()
display.newText(“hello”, 25, 15, native.systemFont, 10);
end

Runtime:addEventListener(“enterFrame”, gameLoop);[/lua]

At the moment this just runs gameLoop over and over making very thick and blury text. [import]uid: 88429 topic_id: 17190 reply_id: 317190[/import]

Try entering this chunk at your line 4 above (after the [lua]end[/lua])

[lua]display.remove(resultText)[/lua]

Regards,
[import]uid: 89165 topic_id: 17190 reply_id: 64768[/import]

you do not create objects in a gameLoop unless they are to be spawned like particles or enemies in a never ending barrage.

so you would have the display.newText(…) outside your game loop.

if you need to change the text to some information, then use it his way

 local text = display.newText("hello",...)  
 local updateText = 1  
  
local function gameLoop()  
 text.text = updatedText  
  
 updatedText = updatedText + 1  
end  
   
Runtime:addEventListener("enterFrame", gameLoop)  

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 17190 reply_id: 64769[/import]

Thanks a bunch guys, once again I feel like a rookie.
My code is now working perfectly. [import]uid: 88429 topic_id: 17190 reply_id: 64773[/import]