O'Reilly logo

Java™ ME Game Programming, Second Edition by Ph.D. Martin J. Wells, Ph.D. John P. Flynt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Key Events

To process key events, you use the getKeyStates() method. This method is called in the lines immediately following comment #3.1 within the scope of the run() method. The run() method, as has been mentioned previously, is supplied by the Runnable interface and allows you to use a Thread object to control the actions of the game loop. Accordingly, in the lines following comment #3, you create instances of a Graphics object to use for rendering by calling the getGraphics() method and then create instances of the Sprite class to assign to the spriteA and spriteB objects. After that, you call the defineReferencePixel() method to place in the two Sprite object reference pixels that might be used for any number of purposes. This sets up the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required