hey
i have a problem with spawning…There will be an image which will move from top of the screen to the bottom…it is created in main menu of the game so that menu doesn’t look boring.
Coding :
local function spawnVirus() local virus = display.newImageRect("menuImages/virus.png",100,100) virus.x = math.random(screenLeft + screenWidth \* 0.1, screenRight - screenWidth \* 0.1) virus.y = screenTop - virus.height trans\_virus = transition.to(virus, { y = screenBottom + virus.height , time =3000}) sceneGroup:insert(virus) end timer\_virus = timer.performWithDelay(2900,spawnVirus,0)
It gives me the following problem when i go to other scene(like options.lua or any other) and come back again to main menu scene
17:55:42.031 C:\Users\admin\Documents\Corona Projects\Game\scene_menu.lua:140: attempt to call method ‘insert’ (a nil value)
17:55:42.031 stack traceback:
17:55:42.031 C:\Users\admin\Documents\Corona Projects\Game\scene_menu.lua:140: in function ‘_listener’
17:55:42.031 ?: in function <?:167>
17:55:42.031 ?: in function <?:169>
line 140 is sceneGroup:insert(virus)
This is my code in options.lua that take me to menu scene
local function onBackTouch( event ) -- body if (event.phase == "ended") then composer.removeScene("scene\_menu") composer.gotoScene("scene\_menu","crossFade") end end