Game Development Reference
In-Depth Information
The [peian object now triggers the kjQl`]paPeia event handler every second:
Peian objects have a property called _qnnajp?kqjp that tells you how many times the timer event has
fired since it started. The kjQl`]paPeia event copies the value of _qnnajp?kqjp to the peia@eolh]u
dynamic text field on the stage:
You can use _qnnajp?kqjp as done here: to display the number of times the event has been triggered.
The eb statement uses _qnnajp?kqjp to check whether ten seconds have elapsed; if they have, it calls
the Peian class's naoap and op]np methods:
naoap stops the timer and also resets _qnnajp?kqjp to zero. To start the timer again, you need to use
the op]np method once more. (If you need to stop the timer completely in any of your games, you can
use the opkl method. opkl stops the timer without resetting _qnnajp?kqjp.)
When you create a Peian object, you can add a second argument, which is known as nala]p?kqjp.
This is a number that tells the timer how many times it should repeat. You can see the effect of using
nala]p?kqjp by updating the directive that creates the [peian object so that it looks like this:
If you test the project, you'll see that the numbers count up to five. After that, the event is no longer
There are a few more Peian class properties that you should know about. If you need to change the
interval between events, you can use the `ah]u property. For example, if you want the timer event to
be triggered every one-half second, you can set the delay to 500 milliseconds, like this:
If you need to know whether a timer is currently running, you can use the nqjjejc property. nqjjejc
returns pnqa when the timer is running and b]hoa when it isn't.
Search Nedrilad ::

Custom Search