Timer

What is the coding needed to display a timer? I have a text box that a number is displayed in when you transition to the screen. Instead of the number showing up immediately. I would like it to show up about 3 - 5 secs after the screen transitions.

Michelle

This is the code for the text field I am talking about.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- show the reminder in a textfield
numberFieldReminder = native.newTextField( 180, 315, 85, tHeight, onnumberFieldReminder)
numberFieldReminder.font = native.newFont( native.systemFontBold, inputFontSize )
numberFieldReminder.inputType = "number"
numberFieldReminder.align = "center"
numberFieldReminder.text = divisionBal
 
 
localGroup:insert(numberFieldReminder)
 
 
-->MUST return a display.newGroup()
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--> This is how we end every file except for director and main, as mentioned in my first comment
        
return localGroup
 
end

read up on timer.performWithDelay, that is what you need.

cheers,

?:)

Yes I've seen them but I'm stumped. It says that it must be tied to an event or listener. My native.TextField does not have either one. I am just displaying a number in the text field and I want it delayed. I don't know how to use the timer without a listener or event. Any help would be appreciated.

try this

initially set it with a blank

numberFieldReminder.text = "" --divisionBal

1
timer.performWithDelay(3000,function() numberFieldReminder.text = divisionBal end)

That worked PERFECT! Now one other question for you. Do I need to do anything like remove it like a runtime listener or anything when I go to other screens? I just want to make sure it will not still be running or in a repeat cycle or something.

Lastly and this is on a different topic kind of. Just out of curiosity, do you know how to adjust text size in nativeTextFields when they show on the Ipad? My textfields this one being one of them with the timer we just set, looks great on the iphone and Ipod touch in the simulator but when I go to the Ipad the numbers look too small in the boxes. Do I need to set up something in my build settings? I have looked in the documentation but I don't see anything about font adjustments in regards to platforms.

That sounded so good, when you said another question for you, it almost felt like questions were the new currency ;)

The timer.performWithDelay does not need to be removed like an event handler., so it will work fine for you. If you want to be 100% sure then add the numberOfTimesToLoop in the function to 1, which is also the default value. [Read the API here ]

Generally as OpenGL does not work very well with native components, like textfields, I have not used them much. So I am not 100% about the scaling issue between the iPhone and the iPad that you mention.

However to increase or decrease your fontSize, you can find out the device your app is running on and set a fontSize according to that. That will be an easier way to manage what you are after.

HINT: read up on system.getInfo, yes you will find what you need there!!

cheers,

?:)

views:1782 update:2011/10/4 17:12:07
corona forums © 2003-2011