[Resolved] Gosts vs Monsters UI question

I’m a Corona beginner and have been using the Ghosts vs Monsters game as an example/template to learn and build my own game.

in the mainmenu.lua file at the beginning of the “new” function it states:
__________________________________________
function new()

local menuGroup = display.newGroup()

local ui = ui --require(“ui”)
local ghostTween
local ofTween
local playTween
local isLevelSelection = false

___________________________________________

In my code that is based off of this, I get an error in the console: “attempt to index upvalue ‘ui’ a (nil value)”

If I change the “local ui=ui” line to "local ui = require(“ui”) everything works fine.

How does the Ghosts vs Monsters code work without having to use the require(“ui”) line?

Thanks,
Chris [import]uid: 146966 topic_id: 27346 reply_id: 327346[/import]

I can’t recall exactly, but as a guess, does Ghosts VS Monsters require ui somewhere else, like in main.lua? If so, that would be why. [import]uid: 52491 topic_id: 27346 reply_id: 111119[/import]

OK I feel silly now as that was the obvious answer and it was right! I thought I kept that portion of the code the same, but I forgot I deleted a couple lines until I saw that I was going to need them including the require UI.

Thanks Peach!

Chris [import]uid: 146966 topic_id: 27346 reply_id: 111136[/import]

No worries Chris - and don’t feel silly, it’s a perfectly easy thing to overlook :slight_smile: [import]uid: 52491 topic_id: 27346 reply_id: 111141[/import]