16
Support / Re: Animating
« on: September 07, 2011, 10:03:07 am »
Cheers for your suggestion - it seems to have improved the smoothness of the animation already. I'll be able to better see how it goes when I get home to my desktop next week. It usually runs at 20-30 fps on that.
A snippet of my code just confirm I am actually implementing what you suggested:
A snippet of my code just confirm I am actually implementing what you suggested:
Code: [Select]
/**
* This method is used for animation - this is the event loop.
*/
public void onDrawFrame(GL10 gl) {
Calendar now = Calendar.getInstance();
if ( previousFrameTime < 0 )
{
previousFrameTime = now.getTimeInMillis();
}
else
{
if ( cameraX < destinationX-1 || cameraX > destinationX+1 )
{
long millisecondsPassed = now.getTimeInMillis() - previousFrameTime;
Float xModifier = 1f;
if ( cameraX > destinationX )
{
xModifier = -1f;
}
cameraX = cameraX + (0.01f * xModifier * millisecondsPassed);
}
previousFrameTime = now.getTimeInMillis();
}
camera.setPosition(cameraX,cameraY,cameraZ-10);