Your images have to be in the same folder as your main.lua or a sub-folder in the folder with your main.lua. You cannot reference things in Windows terms on other drives. By saying C:/PlayButton.png, you’re telling the app to look at the top level of your C drive for the image. Mobile apps cannot work outside their “sandbox”. Put PlayButton.png in the same folder as your main.lua and take off the C:/
I don’t know if this has anything to do with the error or not, but you are missing some required parameters for widget.newButton when using an imageSheet. The docs say:
ImageSheet. Specify the image sheet object for the widget button (instead of graphics files). Requires defaultIndex, overIndex, width, and height to also be set.
So you need to provide defaultIndex, overIndex and the width and height of each button. Try providing those and see if that fixes it. Is PlayButton.png in the same folder as your main.lua?
Sometimes it can be as simple as case-sensitivity. If the filename does not match ‘case’ or is spelled wrong it will fail to find the image and thus nil, and that may result in the message 'bad argument #2 … ’ double check the filename as it is spelled and case-sensitivity. I know that is basic, but sometimes thinking about all the other things that can be wrong, it is easy to miss those things. I know I have.
Not saying for sure this is the issue, it is one of the first things I always check, I am prone to serious tying errors.
Your images have to be in the same folder as your main.lua or a sub-folder in the folder with your main.lua. You cannot reference things in Windows terms on other drives. By saying C:/PlayButton.png, you’re telling the app to look at the top level of your C drive for the image. Mobile apps cannot work outside their “sandbox”. Put PlayButton.png in the same folder as your main.lua and take off the C:/
I don’t know if this has anything to do with the error or not, but you are missing some required parameters for widget.newButton when using an imageSheet. The docs say:
ImageSheet. Specify the image sheet object for the widget button (instead of graphics files). Requires defaultIndex, overIndex, width, and height to also be set.
So you need to provide defaultIndex, overIndex and the width and height of each button. Try providing those and see if that fixes it. Is PlayButton.png in the same folder as your main.lua?
Sometimes it can be as simple as case-sensitivity. If the filename does not match ‘case’ or is spelled wrong it will fail to find the image and thus nil, and that may result in the message 'bad argument #2 … ’ double check the filename as it is spelled and case-sensitivity. I know that is basic, but sometimes thinking about all the other things that can be wrong, it is easy to miss those things. I know I have.
Not saying for sure this is the issue, it is one of the first things I always check, I am prone to serious tying errors.