Hey! I am pulling my hair out over this one bug, so I hope someone out there can PLEASE help me!
Here is the situation:
I start off on scene1; which consists of a slide in panel of menu items (Register , sign in, etc). Here is a snippet of my code for this part:
function registerText( item, text, x, y, size, listener )
options =
{
--parent = textGroup,
text = text,
x = 100,
y = 200,
width = 228, --required for multi-line and alignment
font = “WorkSans-Medium”,
fontSize = 14,
align = “left” --new alignment parameter
}
– body
panel.item = display.newText( options )
panel.item:setFillColor( 0,0,0 )
panel:insert( panel.item ) – THIS IS WHAT’S TRIGGERING THE INSERT NIL ERROR
panel.item.x = display.screenOriginX - x
panel.item.y = display.screenOriginY - y
panel.item:addEventListener( “touch”, listener)
end
When I navigate to a different scene, and then go back to scene1. Sometimes (not every time) when I return back to scene1, a menu item (“New user? register here”) pops up randomly on the screen, accompanied by this error in the console:
stores.lua:2265: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
stores.lua:2265: in function ‘registerText’
stores.lua:2467: in function ‘_callback’
mod_coronium.lua:587: in function ‘onResponse’
mod_coronium.lua:460: in function <mod_coronium.lua:460>
I have a feeling it is due to poor internet connectivity, and if so, how would I go about preventing this happening? If it’s not due to poor internet connectivity, then what could be the cause?
Also, line 2265 refers to panel:insert( panel.item ) which is triggering the insert nil error.
Please please please can someone guide me in the right direction.
Thanks!