Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dashboard effect in Java application



That reminds me- you are sleeping in an application that is having difficulty performing its operations fast enough:

            Thread.sleep(dt);
            repaint();

Whereas you can do something like:

       	start_time = System.currentTimeMillis();

       	paint current frame to buffer
		(so there's no req't to recalculate if paint
		 is called between frames)

	paint(getGraphics());

	sleep_time = start_time + dt - System.currentTimeMillis();

	if (sleep_time > 0) {
	  Thread.sleep(sleep_time);
	}

so you only sleep if you can render the frames fast enough, and then for an amount that lets you update at the frame rate, not some unknown period.


Pete _______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Dashboard effect in Java application (From: Levi Yourchuck <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.