Couple questions - new to Lua

Hello all,

I am new to this so please be gentle lol…

I need to do a mini app for a class using corona and have two events that I don’t know where to get started with:

  1. Load a background image for my app which is one of three pics
  2. On screen swipe play a portion of a .wav file

There is some network junk as well but found a good tutorial that got me through that portion any assistance on how I would do the above two would be great!

[import]uid: 128166 topic_id: 35282 reply_id: 335282[/import]

Got the background image to load correctly… how do I overlay an image on top of it though? [import]uid: 128166 topic_id: 35282 reply_id: 140245[/import]

You can just load another image, or using groups is a good method:

[lua]local imageOne = display.newImage( “image1.png” )
local imageTwo = display.newImage( “image2.png” )

local imageGroup = display.newGroup()

– The order of the following lines affect the image stack
imageGroup:insert( imageOne ) – bottom image
imageGroup:insert( imageTwo ) – top image[/lua]

Hope that helps. Good luck. [import]uid: 202223 topic_id: 35282 reply_id: 140251[/import]

I was using tabBar image but I will try this method as well… is there an easy way to “resize” the overlay image so that it fits the screen my overlay image right now is larger than my background one :frowning: [import]uid: 128166 topic_id: 35282 reply_id: 140253[/import]

make sure you browse ALL of the samples provided w/ corona very closely [import]uid: 32462 topic_id: 35282 reply_id: 140255[/import]

by that I mean run them all in the simulator [import]uid: 32462 topic_id: 35282 reply_id: 140256[/import]

If you want to match the device screen, try:

[lua] imageTwo:scale( display.contentWidth, display.contentHeight )[/lua]

If you want to match it to the “bottom” image:

[lua] imageTwo:scale( imageOne.width, imageOne.height )[/lua]

Check out this page http://developer.coronalabs.com/reference/index/common-properties

Hope that helps. [import]uid: 202223 topic_id: 35282 reply_id: 140258[/import]

And as jflowers45 mentioned, you can learn a lot with the examples. It’s not extremely obvious, but they can be found in your installed Corona SDK folder in Sample Code.

Cheers. [import]uid: 202223 topic_id: 35282 reply_id: 140259[/import]

Thanks guys got most of what I needed on the tutorials… one thing I couldn’t find though was how to “attach” an image to the swipe… so for instance if you have a guitar pic on screen whenever user swipes it uses the “pic”

and also can you play parts of a sound file on two objects interacting? [import]uid: 128166 topic_id: 35282 reply_id: 140272[/import]

Got the background image to load correctly… how do I overlay an image on top of it though? [import]uid: 128166 topic_id: 35282 reply_id: 140245[/import]

You can just load another image, or using groups is a good method:

[lua]local imageOne = display.newImage( “image1.png” )
local imageTwo = display.newImage( “image2.png” )

local imageGroup = display.newGroup()

– The order of the following lines affect the image stack
imageGroup:insert( imageOne ) – bottom image
imageGroup:insert( imageTwo ) – top image[/lua]

Hope that helps. Good luck. [import]uid: 202223 topic_id: 35282 reply_id: 140251[/import]

I was using tabBar image but I will try this method as well… is there an easy way to “resize” the overlay image so that it fits the screen my overlay image right now is larger than my background one :frowning: [import]uid: 128166 topic_id: 35282 reply_id: 140253[/import]

make sure you browse ALL of the samples provided w/ corona very closely [import]uid: 32462 topic_id: 35282 reply_id: 140255[/import]

by that I mean run them all in the simulator [import]uid: 32462 topic_id: 35282 reply_id: 140256[/import]

If you want to match the device screen, try:

[lua] imageTwo:scale( display.contentWidth, display.contentHeight )[/lua]

If you want to match it to the “bottom” image:

[lua] imageTwo:scale( imageOne.width, imageOne.height )[/lua]

Check out this page http://developer.coronalabs.com/reference/index/common-properties

Hope that helps. [import]uid: 202223 topic_id: 35282 reply_id: 140258[/import]

And as jflowers45 mentioned, you can learn a lot with the examples. It’s not extremely obvious, but they can be found in your installed Corona SDK folder in Sample Code.

Cheers. [import]uid: 202223 topic_id: 35282 reply_id: 140259[/import]

Thanks guys got most of what I needed on the tutorials… one thing I couldn’t find though was how to “attach” an image to the swipe… so for instance if you have a guitar pic on screen whenever user swipes it uses the “pic”

and also can you play parts of a sound file on two objects interacting? [import]uid: 128166 topic_id: 35282 reply_id: 140272[/import]