Quick Question

here is the code i have so far… just a image… it doesnt fit the screen though… what should i do?

My code so far:

myImage = display.newImage( “background-16.jpg” ) [import]uid: 19141 topic_id: 5303 reply_id: 305303[/import]

I always find it helpful to declare at the top of the file:

\_W = display.viewableContentWidth; \_H = display.viewableContentHeight;

These then assign the width and height of your screen (adjusting for orientation as well) to variables you can use. 

By default, the image will have a center reference point (don’t get me started on the problems which reference points have caused me) so to center it filling the screen, you should next (after the code in your post) do:

myImage.x = \_W/2; myImage.y = \_H/2; myImage.width = \_W; myImage.height = \_H;

If you then want the image to scale based on the size of the screen, you instead want to make the width and height like this:

myImage.width = \_W - display.screenOriginX; myImage.height = \_H - display.screenOriginY; 

These properties respectively store the difference in width and height between the origin of an iPhone and that of a bigger device. Example, printing display.screenOriginX while viewing on iPhone or iPhone 4 will show 0, but then running the same page on iPhone 5 will print -44. Why? Because the origin (0,0) is 44 pixels furter left from center when using an iPhone 5. So by taking this number off, the image will take off -88 from its width (which means it will add 88). 

Hope this helps!

Hi Madeline.  I would suggest starting here:

http://www.coronalabs.com/resources/tutorials/images-audio-video-animation/

In particular watch the “Loading Image” video.  It will help you understand image loading.

Rob

I always find it helpful to declare at the top of the file:

\_W = display.viewableContentWidth; \_H = display.viewableContentHeight;

These then assign the width and height of your screen (adjusting for orientation as well) to variables you can use. 

By default, the image will have a center reference point (don’t get me started on the problems which reference points have caused me) so to center it filling the screen, you should next (after the code in your post) do:

myImage.x = \_W/2; myImage.y = \_H/2; myImage.width = \_W; myImage.height = \_H;

If you then want the image to scale based on the size of the screen, you instead want to make the width and height like this:

myImage.width = \_W - display.screenOriginX; myImage.height = \_H - display.screenOriginY; 

These properties respectively store the difference in width and height between the origin of an iPhone and that of a bigger device. Example, printing display.screenOriginX while viewing on iPhone or iPhone 4 will show 0, but then running the same page on iPhone 5 will print -44. Why? Because the origin (0,0) is 44 pixels furter left from center when using an iPhone 5. So by taking this number off, the image will take off -88 from its width (which means it will add 88). 

Hope this helps!

Hi Madeline.  I would suggest starting here:

http://www.coronalabs.com/resources/tutorials/images-audio-video-animation/

In particular watch the “Loading Image” video.  It will help you understand image loading.

Rob