尝试索引全局变量“application”(一个空值)的错误

我正在尝试跟随一个 Lua 乱斗课程来学习这种语言,当我尝试运行程序查看标题时,在第 17 行时它出现了错误。

lua: [string "<eval>"]:1: attempt to index global 'application' (a nil value)
stack traceback:
        [string "<eval>"]:1: in main chunk

这是我编写的所有代码和课程链接

application:setOrientation(Application.LANDSCAPE_LEFT

application:setScaleMode("letterbox")

BLACK @ 0x1A1A1A
application:setBackgroundColor(BLACK)

local fg = Bitmap.new(Texture.new("images/foreground.png", true))
fg:setX(1201)
stage:addChild(fg)

YELLOW @ 0xDAD45E
local title = TextField.new(nil, "The Long Dark")
title:setTextColor(YELLOW)
title:setPosition(1320, 100)
stage:addChild(title)

https://programmingbymoonlight.com/roguelike-part-1-lua-and-gideros-an-introduction/

点赞
用户14170654
用户14170654

所以我尝试了 gideros 并且它正常工作,虽然它依赖 lua,但它有自己 IDE 框架本身的命令。

2020-08-27 14:18:19