简体   繁体   中英

Corona SDK Director class error on device

I have a problem with Director v 1.4 when testing on the device (iPhone). The simulator is not showing any errors, but they come up on the device. Here is the error:

slotMachine[1206] <Warning>: Runtime error
?:0: attempt to call method 'insert' (a nil value)
stack traceback:
    [C]: in function 'insert'
    ?: in function 'changeScene'
    ?: in function <?:13>
    ?: in main chunk

And here is the main.lua:

    display.setStatusBar( display.HiddenStatusBar )



local director = require("director")



local mainGroup = display.newGroup()



local main = function ()


    mainGroup:insert(director.directorView)



    director:changeScene("menu1", "overFromBottom")



    return true
end


main()

And this is menu1.lua:

    module(...,package.seeall)



new = function ( params )

    local GGData = require( "GGData" )

local _W = display.contentWidth --Width and height parameters
local _H = display.contentHeight


    local localGroup = display.newGroup()
local box = GGData: load( "credits" )
local background = display.newImageRect("images/machine_bg.png",640,960)
background.x = _W*0.5; 
background.y = _H*0.800;

local currentBalance = display.newText("Current Balance:\n$"..box.credits, 0,0,400,0, "Quicksand", 25)
currentBalance:setTextColor(44, 62, 80)
currentBalance:setReferencePoint(display.CenterLeftReferencePoint)
currentBalance.x = _W - 265; currentBalance.y = _H *0.17;


localGroup:insert (background)
localGroup:insert (currentBalance)





    return localGroup

end

Director is a quite old library; you will want to start using Storyboard. Though it may seem more difficult to begin with, in the end, you'll be glad you did it - it's officially supported by Corona (meaning active development as the SDK is upgraded) and more powerful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM