Corona Simulator Syntax Error (Unexpected Symbol)

假装没事ソ 提交于 2019-12-24 16:25:33

问题


I am making a Lua app. Here is the main.lua code:

(This is on Mac.)

display.setStatusBar (display.HiddenStatusBar)
local main.lua = require ("main.lua")             --[LINE WITH ERROR]
local director = require ("director")
local mainGroup = display.newGroup()

local function main()
    mainGroup:insert(director.directorView)
    director:changeScene("mainPage")
    return true
end

main()

And here is my error report after, it is pretty simple, but I'm not sure what it is about:

Corona Simulator Syntax Error

File: /Users/[my computer name]/Desktop/Corona App/main.lua
Line: 4

Unexpected symbol near '.'

回答1:


The syntax for locals is local <simple-name>. So, main.lua is not allowed here.




回答2:


You just need to do as follows (in your main.lua):

display.setStatusBar(display.HiddenStatusBar)
local director=require("director")
local maingroup=display.newGroup()
maingroup:insert(director.directorView)
director:changeScene("yourFirstScene")
return maingroup

Note: Make sure that director.lua and yourFirstScene.lua are present in the same folder where your main.lua exists

Keep Coding.......... :)




回答3:


Do not write:

local main.lua = require ("main.lua") -- as 'lhf' said.

If you are using director class, then as krs said, you need to only add the following lines to main.lua:

  local director=require("director")  -- import director class(make sure the class exist)
  local parentGroup=display.newGroup() -- create new display group namely 'parentGroup'
  parentGroup:insert(director.directorView) -- insert director view to 
  director:changeScene("yourFirstScene") -- call next class(make sure the class exist)
  return parentGroup -- return 'parentGroup'



回答4:


local main.lua = require ("main.lua")

So that is your code. Do not type that, type this

local main = require ("main.lua")


来源:https://stackoverflow.com/questions/20083550/corona-simulator-syntax-error-unexpected-symbol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!