timing in J2ME

Hello!

I am new to J2ME and I trying to figure out how to make some moves through time, but unsuccesufuly.

If I do some FOR loop, how can I set it to wait for example 1 second before passing again. So if the loop should pass 100 that means I would like FOR loop to wait 1 second everytime it passes this loop? So all toughether the whole FOR statement will need some 100 seconds to be done.

How is that possible? In applet I found some sleep function, but it seems that doesn't work in J2ME.

Can someone direct me how to solve problem. Any simple code will help.

[595 byte] By [coolatora] at [2007-9-28 9:51:26]
# 1

You could do (none work peusdo code follow)

while( running ) {

long start = System.currentTimeMills();

doX();

repaint();

serviceRepaints();

while( start - System.currentTimeMills() > XYZ );

}

or (as I am playing with now)

long frameTime;

while( running ) {

long start = System.currentTimeMills();

doX();

repaint();

serviceRepaints();

frameTime = start - System.currentTimeMills();

}

And using the frameTime to control how many pixels I move an object.

mlka at 2007-7-11 23:21:22 > top of Java-index,Other Topics,Java Game Development...