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. [import]uid: 22300 topic_id: 17704 reply_id: 317704[/import]

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? [import]uid: 70847 topic_id: 17704 reply_id: 67471[/import]

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

Ziad.

[import]uid: 22300 topic_id: 17704 reply_id: 67474[/import]

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;
[lua]local splash = display.newImageRect(“splash.png”, width, height)
splash.x = 160
splash.y = 240[/lua]

That should work. Can you try it and let me know, please? (You could also use contentWidth and height to position, obviously.)

Peach :slight_smile: [import]uid: 52491 topic_id: 17704 reply_id: 67477[/import]

Thanks Peach, it worked the first time!

Ziad. [import]uid: 22300 topic_id: 17704 reply_id: 67479[/import]

Peach beat me to it … :frowning:
(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
[lua]local splash = display.newImageRect(“Splash.png”,320,480);
splash:setReferencePoint(display.TopLeftReferencePoint);
splash.x = 0;
splash.y = 0;[/lua]

[import]uid: 70847 topic_id: 17704 reply_id: 67480[/import]

Thanks for this, ingemar. This will be handy in some other code I am writing. [import]uid: 22300 topic_id: 17704 reply_id: 67481[/import]

My bad - at some point during that I got thinking about newRect instead :wink:

Thanks for that ingemar - have edited it.

Peach :slight_smile: [import]uid: 52491 topic_id: 17704 reply_id: 67494[/import]