Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


n3oplasm

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

#5001006 NullPointerException on DoubleBuffering

Posted by n3oplasm 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!

http://docs.oracle.com/javase/tutorial/extra/fullscreen/bufferstrategy.html
http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-active-rendering-r2418


#4998540 Programming Exercises

Posted by n3oplasm 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.

http://math.hws.edu/javanotes/


#4997658 Building Games for Android

Posted by n3oplasm 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


PARTNERS