Hello,
so, that’s my first time when I used Corona&Composer. When I run my game at simulator it’s fine and no errors. But when I build it to android I got Runtime error: table excepted. If this is a function call, you might have used “.” instead of “:”. I tried many ways, and I find the problem in this lines:
sceneGroup:insert(background) sceneGroup:insert(noad) sceneGroup:insert(play)
So, below you can see all my menu.lua code:
--------------------------------------------------------------------------------- -- -- scene.lua -- --------------------------------------------------------------------------------- local sceneName = menu local composer = require "composer" local store = require( "plugin.google.iap.v3" ) local appodeal = require( "plugin.appodeal" ) -- Initialize the Appodeal plugin local widget = require "widget" -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) local background,play,noad --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view background = display.newImage("menu.png", display.contentCenterX, display.contentCenterY) store.loadProducts( productIdentifiers, productListener ) local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) end end appodeal.init( adListener, { appKey="KEY" } ) appodeal.show( "banner", { yAlign="top" } ) local function transactionListener( event ) if not ( event.transaction.state == "failed" ) then -- Successful transaction appodeal.hide("banner") else -- Unsuccessful transaction; output error details end end store.init( transactionListener ) play = widget.newButton{ defaultFile = "play\_btn.png", overFile = "play\_btn\_push.png", onRelease = function () composer.gotoScene( true, "game", "slideLeft", 300 ) end, } noad = widget.newButton{ defaultFile = "noad\_btn.png", overFile = "noad\_btn\_push.png", onRelease = function () store.purchase( "noad" ) end, } play.x = display.contentCenterX; play.y = display.contentCenterY; noad.x = display.contentCenterX; noad.y = display.contentHeight-350; sceneGroup:insert(background) sceneGroup:insert(noad) sceneGroup:insert(play) function SaveRecord() -- Data (string) to write local saveData = tostring(composer.Record) -- Path for the file to write local path = system.pathForFile( "Data.txt", system.DocumentsDirectory ) -- Open the file handle local file, errorString = io.open( path, "w" ) if not file then -- Error occurred; output the cause print( "File error: " .. errorString ) else -- Write data to file file:write( saveData ) -- Close the file handle io.close( file ) end file = nil end -- Path for the file to read function LoadRecord() local path = system.pathForFile( "Data.txt", system.DocumentsDirectory ) local file, errorString = io.open( path, "r" ) if not file then -- Error occurred; output the cause else -- Read data from file composer.Record = tonumber(file:read( "\*a" )) if (composer.Record == -100) then composer.Record=0 SaveRecord() end io.close( file ) end file = nil end LoadRecord() -- Called when the scene's view does not exist -- -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene -- e.g. stop timers, stop animation, unload sounds, etc.) elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene