I just started using Corona last night and am trying to learn the Lua scripting language it uses… I am having with what I assume is pretty basic function and it’s starting to bother me.
So I have a splash function to display a splash screen for 2 seconds then move on to the title function to display the title screen. The title screen uses transparency so when it displays it is displaying over top of the splash screen which remains on the screen. I thought the proper way to prevent this from happening would be with splashScreen.isVisible = false; but that doesn’t seem to do anything for me.
[code]-- ************************************************** –
– title screen
title = function()
local titleScreen = display.newImage(“images/title.png”)
end
– ************************************************** –
– splash screen
splash = function()
local splashScreen = display.newImage(“images/splash.png”)
timer.performWithDelay(2000,title,1)
end
– ************************************************** –
– main function
main = function()
display.setStatusBar(display.HiddenStatusBar)
splash()
end
So if your question was, how can I make the splashscreen visible, then look here:
[lua]–Predefine the variable that holds the splashscreen object
local splashScreen
– ************************************************** –
– title screen
title = function()
splashScreen.isVisible = false
local titleScreen = display.newImage(“images/title.png”)
end
Thanks a ton Michael! I was able to change the code over lunch and that fixed it.
Just so I know where I went wrong here… I’m assuming that by declaring the variable within the function it was then acting as local variable - but by declaring at the start of the code, outside of any functions, it is acting as a global variable? [import]uid: 10267 topic_id: 2905 reply_id: 8503[/import]
Exactly. A local declare inside a block (even an IF THEN END or a FOR END) is only visible in that scope and under it. If you declare a local on top, it acts like a global variable. You need to do the same with names of functions that are called from a location above their creation. [import]uid: 5712 topic_id: 2905 reply_id: 8536[/import]