How to add a splash screen in Lua.

Hi All,

How can I add a fullscreen splash screen in my app. Currently I am doing this with the following code. But I am not sure about the way I do.

splashscreen = display.newImage( “images/default.png” );

local function removeSplash(event)
splashscreen:removeSelf()
splashscreen = nil
end
timer.performWithDelay(2000,removeSplash)

Using this code image is not cvering the whole screen. I appears only a portion of the screen only.

Is there any other way to display splash screen.
Please suggest… [import]uid: 154400 topic_id: 35185 reply_id: 335185[/import]

i would reccomend to take a look at the storyboard API and the Overlay function :slight_smile:

http://developer.coronalabs.com/content/storyboard [import]uid: 134049 topic_id: 35185 reply_id: 139904[/import]

You can see this post for splash screens:
http://developer.coronalabs.com/forum/2013/01/05/splash-screen-transition

For dealing with images that fill the whole screen you can have a look at this:
http://j.mp/GIZX4p

[import]uid: 70847 topic_id: 35185 reply_id: 139917[/import]

You can put the following images in the root folder.

Default.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png

Or…

Set you config.lua to “zoomStretch” and try
[lua]splashscreen = display.newImage( “images/default.png”, 0, 0, true );
splashscreen.x = display.contentCenterX
splashscreen.y = display.contentCenterY

local function removeSplash(event)
splashscreen:removeSelf()
splashscreen = nil
end

timer.performWithDelay(2000,removeSplash)[/lua]
This post (content-scaling-made-easy) is really helpful, search for The “magic recipe”. If you use this, you can set your config to “letterbox”

Hope some of this can help. [import]uid: 202223 topic_id: 35185 reply_id: 139938[/import]

i would reccomend to take a look at the storyboard API and the Overlay function :slight_smile:

http://developer.coronalabs.com/content/storyboard [import]uid: 134049 topic_id: 35185 reply_id: 139904[/import]

You can see this post for splash screens:
http://developer.coronalabs.com/forum/2013/01/05/splash-screen-transition

For dealing with images that fill the whole screen you can have a look at this:
http://j.mp/GIZX4p

[import]uid: 70847 topic_id: 35185 reply_id: 139917[/import]

You can put the following images in the root folder.

Default.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png

Or…

Set you config.lua to “zoomStretch” and try
[lua]splashscreen = display.newImage( “images/default.png”, 0, 0, true );
splashscreen.x = display.contentCenterX
splashscreen.y = display.contentCenterY

local function removeSplash(event)
splashscreen:removeSelf()
splashscreen = nil
end

timer.performWithDelay(2000,removeSplash)[/lua]
This post (content-scaling-made-easy) is really helpful, search for The “magic recipe”. If you use this, you can set your config to “letterbox”

Hope some of this can help. [import]uid: 202223 topic_id: 35185 reply_id: 139938[/import]

splashscreen = display.newImage( “LoadScreen.png”,480,320 );

splashscreen.x, splashscreen.y = display.contentWidth / 2, display.contentHeight / 2

local function removeSplash(event)

splashscreen:removeSelf()

splashscreen = nil

end 

timer.performWithDelay(2000,removeSplash)

WORKS LIKE A CHARM! I only figured this out cause of you though! thanks!

oh it only works for iPhone 5 and 5s though.

Hey,

You can substitute:
[lua][color=rgb(40,40,40)][font=Helvetica, Arial, Verdana, sans-serif]splashscreen = display.newImage( “LoadScreen.png”,480,320 );[/lua][/font][/color]
for
[lua][color=rgb(40,40,40)][font=Helvetica, Arial, Verdana, sans-serif]splashscreen = display.newImage( “LoadScreen.png”,display.contentHeight,display.contentWidth);[/lua][/font][/color]

This should always fill the screen. However, this will also skew the image to fit within these proportions, which might be undesirable…

Rich

Bloody formatter…

and again…

You can substitute:

  1. [lua]splashscreen = display.newImage( “LoadScreen.png”,480,320 );[/lua]

for

[lua]splashscreen = display.newImage( “LoadScreen.png”,display.contentHeight,display.contentWidth);[/lua]

This should always fill the screen. However, this will also skew the image to fit within these proportions, which might be undesirable…

Rich

What scale setting are you using?

splashscreen = display.newImage( “LoadScreen.png”,480,320 );

splashscreen.x, splashscreen.y = display.contentWidth / 2, display.contentHeight / 2

local function removeSplash(event)

splashscreen:removeSelf()

splashscreen = nil

end 

timer.performWithDelay(2000,removeSplash)

WORKS LIKE A CHARM! I only figured this out cause of you though! thanks!

oh it only works for iPhone 5 and 5s though.

Hey,

You can substitute:
[lua][color=rgb(40,40,40)][font=Helvetica, Arial, Verdana, sans-serif]splashscreen = display.newImage( “LoadScreen.png”,480,320 );[/lua][/font][/color]
for
[lua][color=rgb(40,40,40)][font=Helvetica, Arial, Verdana, sans-serif]splashscreen = display.newImage( “LoadScreen.png”,display.contentHeight,display.contentWidth);[/lua][/font][/color]

This should always fill the screen. However, this will also skew the image to fit within these proportions, which might be undesirable…

Rich

Bloody formatter…

and again…

You can substitute:

  1. [lua]splashscreen = display.newImage( “LoadScreen.png”,480,320 );[/lua]

for

[lua]splashscreen = display.newImage( “LoadScreen.png”,display.contentHeight,display.contentWidth);[/lua]

This should always fill the screen. However, this will also skew the image to fit within these proportions, which might be undesirable…

Rich

What scale setting are you using?

Any chance of seeing an updated version of this for Composer?  I am looking at sample files for composer and so far none have a splash.lua.

You can just adjust the scale of the image to fit the whole screen. 

Any chance of seeing an updated version of this for Composer?  I am looking at sample files for composer and so far none have a splash.lua.