Display a background based on time?

Hiya.

I’m making a book with Corona, and want to display a different set of pages depending on the time of day. I figure this means writing a quick if/then statement, displaying a different background whether os.time >=x or <= x. But do you have any pointers on how to specifically phrase something like this? I’m using the Storyboard API, if that makes any difference.

I appreciate your help. [import]uid: 121838 topic_id: 22945 reply_id: 322945[/import]

Hey there, this code would show a dark red rectangle background half the day and a dark blue the other half - have a play with it;

[lua]display.setStatusBar (display.HiddenStatusBar)

local time = os.date(’*t’)
local hour = time.hour

local function setBackground ()
if hour <= 12 then
local background = display.newRect( 0, 0, 320, 480 )
background:setFillColor(100,0,0)
elseif hour >= 13 then
local background = display.newRect( 0, 0, 320, 480 )
background:setFillColor(0,0,100)
end
end
setBackground()[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 22945 reply_id: 91673[/import]