FX animations - Capture the falling objects
By mohanpraveen on Aug 13, 2007
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.
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.