| View previous topic :: View next topic |
| Author |
Message |
justatest
Joined: 19 Dec 2005 Posts: 10
|
Posted: Mon Jan 09, 2006 5:25 pm Post subject: how to do something frequently ? |
|
|
i hope to do a thing in every 2 sec . or some how .
but lua seem have no interrupt etc . i read some codes . but still not get the meaning .
screen.waitVblankStart(4) seem some like this . some one pls give me some more detail ? |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Mon Jan 09, 2006 5:39 pm Post subject: |
|
|
| screen.waitVblankStart(4) is a timer that halts all code for x ammount of time. Each numerical digit works in MS so if you wanted it to wait 2 seconds you would give it a timeout of 200(or 2000) depending on how long you wanted to wait. 200 I believe is 2 seconds. |
|
| Back to top |
|
 |
MikeHaggar
Joined: 18 Jul 2005 Posts: 116
|
Posted: Tue Jan 10, 2006 3:05 am Post subject: |
|
|
| Um... VBlanking happens 60 times a second me thinks (60FPS/60Hz or whatever), so screen.waitVblankStart(120) would be 2 seconds? |
|
| Back to top |
|
 |
KawaGeo
Joined: 27 Aug 2005 Posts: 191 Location: Calif Mountains
|
Posted: Tue Jan 10, 2006 3:13 am Post subject: |
|
|
Use system.sleep(x) function instead, x in milliseconds. _________________ Geo Massar
Retired Engineer |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Tue Jan 10, 2006 12:28 pm Post subject: |
|
|
| Waiting a specific time i always use a timer only because its far more relyable to do it that way vs halting everything going on. |
|
| Back to top |
|
 |
LordCthulu
Joined: 29 Dec 2005 Posts: 11
|
Posted: Wed Jan 11, 2006 12:10 am Post subject: |
|
|
Hey romero can you give me a quick example of using a timer like that?
I tried using a timer for animation but I couldn't get it to work. Thanks in advance ^^; |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Wed Jan 11, 2006 12:15 am Post subject: |
|
|
for a limitation do.. if timer:start() > 30 then
pretty much.. it limites that timer to 30ms .. giving you a fps based animation or etc.. timer:reset() resets the timer.. the rest of the information can be found on the wiki |
|
| Back to top |
|
 |
LordCthulu
Joined: 29 Dec 2005 Posts: 11
|
Posted: Wed Jan 11, 2006 8:52 am Post subject: |
|
|
| Ok I was checking for something other than timer:start(), probably why. Thanks ^^; |
|
| Back to top |
|
 |
|