Praveen's Blog
FX animations - Capture the falling objects
As a continuation of my learning process, I wanted to find out What would it take to write a blocks game in FX. Though I have not made the progress that I promised on using the FX animation loops in lieu of Swing Timer, I made little progress over capturing keyboard interactions from the user using 'onKeyDown' of the Canvas and 'KeyboardAction'. In general, it was simple & straightforward to just associate a keystroke with an operation using the KeyboardAction, for any FX widget and there are enumerated values for most of the keystrokes. The same values could be used in the 'mnemonic' attribute as well.
But some mnemonics doesn't seem to work for me. For ex, I want to use ESCAPE as a mnemonic for a 'cancel' button in a dialog whose action would be close the dialog. I am still not successful in getting this work. I need to find out if ESC keystroke is getting consumed by the top-level or by the native.
FX Blocks
Here is a small game where objects keep falling from the top and the player has to move the cup at the bottom using keyboard/mouse capture those objects. You can configure the size of the object and the speed with which the objects reach the bottom.
(Click on the image to launch the game. You would need jdk6+)
Next I would like to go into transformations & clipping of individual objects and groups as a whole.. Stay tuned.
Posted at 07:01PM Aug 13, 2007 by mohanpraveen in Sun | Comments[3]

Nice little program. Do the falling balls move at different times because you are using the animation loops as opposed to a timer to update everything at once?
Posted by Ryan S on August 14, 2007 at 12:59 AM IST #
Not really. I have written in such a way that New balls are introduced during every alternate iterations and balls are moved in every iteration. That's why you feel as if balls are moving at different speeds.
Posted by praveen on August 14, 2007 at 05:41 PM IST #
ez
Posted by 76.247.173.136 on May 31, 2008 at 08:13 AM IST #