Attempt to Index local 'background' (a nil value)

Hi

I am in need of help. I was working on my game on my Windows machine and all worked OK. Now I transferred the game folder to my mac machine for key signing and publishing but for some reasons, corona simulator is giving me the above error message and I am unable to run the game.

What am i doing wrong even tough the same game runs on the Windows version of corona.

        local background = display.newImage( "/images/background-image.png" )         background.x = centerX         background.y = centerY

That should probably be something with your path.

Try this: 

 local background = display.newImage( "images/background-image.png" )

Ah thanks, the first slash was the problem. it looks like mac does not like it but the Windows version likes it. I hope this won’t affect the game.

Technically speaking when you start a path with “/” it means to start from the very top of the hard drive’s directory structure.  OS-X (and iOS for that matter) are built on Unix and that’s the natural behavior of the OS.  Windows OS is a little bit different and while that / should have meant the root folder, (the /'s get converted into 's, the current drive letter, i.e. C: gets appended on, etc.), it’s likely in that conversion process, with out the drive letter at the beginning, the first slash may be getting removed.  I’m not really sure how that works under the Window’s hood…  But I can see the Windows filesystem calls protecting itself that way.

So when you leave off the front slash, you are implying a relative path under your current working directory.

Rob

That should probably be something with your path.

Try this: 

 local background = display.newImage( "images/background-image.png" )

Ah thanks, the first slash was the problem. it looks like mac does not like it but the Windows version likes it. I hope this won’t affect the game.

Technically speaking when you start a path with “/” it means to start from the very top of the hard drive’s directory structure.  OS-X (and iOS for that matter) are built on Unix and that’s the natural behavior of the OS.  Windows OS is a little bit different and while that / should have meant the root folder, (the /'s get converted into 's, the current drive letter, i.e. C: gets appended on, etc.), it’s likely in that conversion process, with out the drive letter at the beginning, the first slash may be getting removed.  I’m not really sure how that works under the Window’s hood…  But I can see the Windows filesystem calls protecting itself that way.

So when you leave off the front slash, you are implying a relative path under your current working directory.

Rob