Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How do I display an image?
Started by whe18000229 Mar 08 2019 07:01 AM

4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

whe18000229

[GLOBAL: userInfoPane.html]
whe18000229
  • Observer

  • 4 posts
  • Corona SDK

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?

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,529 posts
  • Enterprise

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



[TOPIC: post.html]
#3

yvandotet

[GLOBAL: userInfoPane.html]
yvandotet
  • Contributor

  • 184 posts
  • Corona SDK

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



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 674 posts
  • Corona SDK

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



[TOPIC: post.html]
#5

juandariogarciagimeno

[GLOBAL: userInfoPane.html]
juandariogarciagimeno
  • Observer

  • 2 posts
  • Corona SDK

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


[topic_controls]
[/topic_controls]