Until now I read that you should not use more then one timer.
boolean jumping:
long startTime;
if(!jumping)
{
if(keyJump )
startTime=System.currentTimeMillis();
}
else
{
long jumpTime=System.currentTimeMillis()-startTime;
//update player jump
}
Above is a little snippet that I found. It does not work if you compile it with java but shows that you can use System.currentTimeMillis() for getting timing that you can use to smoothly animate a jump.
I just found http://www.java4k.com I found it before but I forgot about it. I found a game that has jumping in it and am about to look through it. I am also looking through the other games to see if there is anything useful in it. The sourcecode suplied with the games can be pasted into the java editor.
Update :
I spend a hour or so trying to find a simple applet gravity bouncing ball/object but I could not find anything. I am now trying to find information on timers.
Geen opmerkingen:
Een reactie posten
Opmerking: Alleen leden van deze blog kunnen een reactie posten.