How do I display an image?

I’m trying to make a game and I’m having a problem with getting images to show (I don’t know how I’m going to get through this considering I can’t even get an image to show properly)

I do not know what I’m doing incorrectly, I placed them correctly, got the correct folder name that they are in and everything but they still refuse to show up. Any help?

Do you ever call your Main() function?

Lua isn’t C. main.lua is the equivalent of the int main( int argc, char *argv[]) {} function.

Since Lua is a single pass compiler, it will start processing line one and go until there is no more code. It doesn’t look for a function named main() to execute for you.

As I mentioned, Lua is a single pass compiler, so unlike C you need to write your code in reverse order to avoid doing everything in global scope:

local function startButtonListeners(action) ...  end local function Main()  ... end Main()

Rob

Hello,

to insert an element to a group, use titleView:insert(image), or display.newImage(titleView,‘assets/image.png’,100,100)

https://docs.coronalabs.com/guide/graphics/group.html

Yvan

Posting more code would be helpful.

Do you run Main()? Do you create other display objects that might be in front of them? Do you apply some alpha to them and are they within bounds of your config.lua, etc. etc.?

Try running just one line of code. Comment everything out apart from creating a single image. If it works then, then you’ve got some issues elsewhere. Also, it is recommended that you actually use https://docs.coronalabs.com/api/library/display/newImageRect.html

Have you called your Main() function? If so, have you tried doing some print() inside it to test if it’s effectively running?

Do you ever call your Main() function?

Lua isn’t C. main.lua is the equivalent of the int main( int argc, char *argv[]) {} function.

Since Lua is a single pass compiler, it will start processing line one and go until there is no more code. It doesn’t look for a function named main() to execute for you.

As I mentioned, Lua is a single pass compiler, so unlike C you need to write your code in reverse order to avoid doing everything in global scope:

local function startButtonListeners(action) ...  end local function Main()  ... end Main()

Rob

Hello,

to insert an element to a group, use titleView:insert(image), or display.newImage(titleView,‘assets/image.png’,100,100)

https://docs.coronalabs.com/guide/graphics/group.html

Yvan

Posting more code would be helpful.

Do you run Main()? Do you create other display objects that might be in front of them? Do you apply some alpha to them and are they within bounds of your config.lua, etc. etc.?

Try running just one line of code. Comment everything out apart from creating a single image. If it works then, then you’ve got some issues elsewhere. Also, it is recommended that you actually use https://docs.coronalabs.com/api/library/display/newImageRect.html

Have you called your Main() function? If so, have you tried doing some print() inside it to test if it’s effectively running?