Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Nov 2012
Offline Last Active Dec 15 2012 03:58 PM

#5001006 NullPointerException on DoubleBuffering

Posted by on 14 November 2012 - 02:39 PM

The call to this.getGraphics() will return null if the component is not visible (i.e. the panel has been added to a JFrame which is not currently set to visible at the time the thread is running). My guess is that finalGraphics is null at the time finalGraphics.drawImage(bfi,0,0,null); is being called. As far as I know, a call to getGraphics (or the preferred createGraphics as TheChubu pointed out) of a BufferedImage object should not return null.

Also, unless there's a reason you aren't currently, I'd consider using the BufferStrategy class that the Java library provides for double-buffering. See the links below for examples of usage in an active-rendering loop. Hope that helps!


#4998540 Programming Exercises

Posted by on 07 November 2012 - 01:46 PM

Here's a free online book on Java that has exercises at the end of each chapter and their solutions as well.


#4997658 Building Games for Android

Posted by on 05 November 2012 - 12:18 PM

Been working with Android myself lately and this book has been an awesome resource so far. Also, as far as engines go, the most promising looking ones I've come across are:

libgdx: http://libgdx.badlogicgames.com/
AndEngine (2d only): http://www.andengine.org/

The GoogleDevelopers YouTube channel might also be a good resource... for example here's a good presentation I found a while back on Android game development: Google I/O 2009 - Writing Real-Time Games for Android