Here’s an example;
[lua]–Hide the status bar
display.setStatusBar(display.HiddenStatusBar)
–Create a new rectangle for the background, color it red
local background = display.newRect( 0, 0, 320, 480 )
background:setFillColor( 255, 80, 80 )
–The number of days remaining
local dayText = display.newText( “”, 0, 0, native.systemFontBold, 160 )
dayText:setTextColor( 0, 0, 0, 200 )
dayText.x, dayText.y = 110, 90
–The number of hours remaining
local hourText = display.newText( “”, 0, 0, native.systemFontBold, 160 )
hourText:setTextColor( 0, 0, 0, 120 )
hourText.x, hourText.y = 110, 240
–The number of minutes remaining
local minutesText = display.newText( “”, 0, 0, native.systemFontBold, 160 )
minutesText:setTextColor( 0, 0, 0, 65 )
minutesText.x, minutesText.y = 110, 390
– Create labels to indicate what the numbers mean
local dayLabel = display.newText( "days ", 0, 0, native.systemFont, 40 )
dayLabel:setTextColor( 255, 255, 255 )
dayLabel.x = 220; dayLabel.y = 100
local hourLabel = display.newText( "hours ", 0, 0, native.systemFont, 40 )
hourLabel:setTextColor( 255, 255, 255 )
hourLabel.x = 220; hourLabel.y = 250
local minuteLabel = display.newText( "minutes ", 0, 0, native.systemFont, 40 )
minuteLabel:setTextColor( 255, 255, 255 )
minuteLabel.x = 210; minuteLabel.y = 400
–Function to update the countdown clock
local function updateTime()
local time = os.date("*t")
local daysLeft = 358 - time.yday
if (daysLeft < 10) then
daysLeft = “0” … daysLeft
end
dayText.text = daysLeft
local hoursLeft = 23 - time.hour
if (hoursLeft < 10) then
hoursLeft = “0” … hoursLeft
end
hourText.text = hoursLeft
local minutesLeft = 60 - time.min
if (minutesLeft < 10) then
miunteText = “0” … minutesLeft
end
minutesText.text = minutesLeft
end
–Update the time once immediately to display the correct time
updateTime()
– Update the clock once per second
local clockTimer = timer.performWithDelay( 1000, updateTime, -1 )[/lua]
I wrote that today for the iPhone. If you run it you will see that it also displays fine in the iPhone 4. It will also show fine in the iPad. (Provided you set scale to something other than “none” in config.lua.)
See how it displays fine? Coords are all good. You may want higher quality images however for the big displays. (Ghosts VS Monsters has an example of using @2x for this.)
Make sense?
Peach
[import]uid: 52491 topic_id: 18723 reply_id: 72134[/import]