Dynamic scaling of Splash Screen

Hi all,

I am building an APP together with a few HS students. We wanted to reduce the number of screens so the "credits" are on the initial screen. The students have produced "Splash.png" (320x480) and "Splash@2x.png" (640x960), both at 72px.

If I use newImage("Splash.png"), the @2x file does not display in iPhone 4. If I use newImageRect("Splash.png", 320, 480) then regardless of which file is picked up by the simulator, the image is displayed in the top left quarter of the screen. How can I make it fill the screen?

My config.lua looks like this:

application =
{
content =
{
width = 320,
height = 480,
scale = "letterbox",
fps = 30,

imageSuffix =
{
["@2x"] = 2,

},
},
}

Sincerely,
Ziad.

That sounds a bit weird. From what you've explained it should work.
What platform are you using, and which build of Corona do you have?

I am using Corona Version 2011.591 (2011.8.2) on Mac OS X 10.7

Ziad.

Hey Ziad,

It has been awhile but I'm quite sure if you use newImageRect and then manually position it on the following lines it will work fine.

Eg;

1
2
3
local splash = display.newImageRect("splash.png", width, height)
splash.x = 160
splash.y = 240

Thanks Peach, it worked the first time!

Ziad.

Peach beat me to it ... :-(
(however you can't specify x,y in the parameters)

She's right. When you use newImageRect, the reference point is in the center of the image, that's why you only see a quarter of the image.

You can also change the reference point like this

1
2
3
4
local splash = display.newImageRect("Splash.png",320,480);
splash:setReferencePoint(display.TopLeftReferencePoint);
splash.x = 0;
splash.y = 0;

Thanks for this, ingemar. This will be handy in some other code I am writing.

My bad - at some point during that I got thinking about newRect instead ;)

Thanks for that ingemar - have edited it.

Peach :)

views:1474 update:2011/11/17 9:28:17
corona forums © 2003-2011