设备上的Corona SDK Director类错误

时间:2013-11-18 13:39:18

标签: ios class lua corona

在设备(iPhone)上进行测试时,我遇到了Director v 1.4的问题。模拟器没有显示任何错误,但它们出现在设备上。这是错误:

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

这是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()

这是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

1 个答案:

答案 0 :(得分:0)

导演是一个非常古老的图书馆;你会想要开始使用Storyboard。虽然开始看起来似乎比较困难,但最终你会很高兴你做到了 - 它得到了Corona的正式支持(意味着在升级SDK时积极开发)并且功能更强大。