Sun recently released the JavaFX 1.1 SDK so I decided to give it a try. I decided to write a PaiGow game. Here is the webstart link:
src="http://www.curtiszerro.com/paigowfx/webstart.jpg" alt="" />
The availability of binds and triggers make the JavaFX scripts very clean.
The animation API is also very easy to use. The reference on the website was also pretty good. I primarily used animation for when the cards are being dealt.
var timelineXOne: Timeline = Timeline {
keyFrames: [
at (0s) {animX => 450.0},
at (.25s) {animX => 37.0 tween Interpolator.LINEAR},
at (.25s) {animX => 450.0},
...
One random thing I had to figure out (because they weren’t referenced on the site) was how to do type casting. JavaFX actually supports it with the “as” keyword.
...
var lowHand = Main.player.getLowHand() as PaiGowHand;
var highHand = Main.player.getHighHand() as PaiGowHand;
...
Here is the place bet scene.

Here is the main game playing surface. The cards are draggable are drag ‘n dropped into target slots. I use a reusable CardDrag controller object for the cards’ drag ‘n drop. Then I use bind on the targets to indicate when all cards have been placed.

Here is the result scene.

I use a scene controller to control the transitioning of the scene when the state is changed.
public function getInstance(): SceneController {
if(controllerInstance == null) {
controllerInstance = SceneController{
scene: Login.scene
};
Login.timelineXOne.play();
}
return controllerInstance;
}
public class SceneController {
public-read var scene: Scene;
public function updateScene(newScene: Scene): Void {
delete scene.content;
scene.content = newScene.content;
}
}
I enjoyed the amount of available API that JavaFX has easily available to use for effects. This helps making flashy and neat text really easy. For example, to add a drop shadow is as easy as (below)…
var dealerLowHandDropTitle = Text {
font: Font.font("Verdana",FontWeight.BOLD,12)
x: 340, y: 100
content: "Low Hand: {dealerLowHandType}"
fill: Color.WHITE
effect: DropShadow {
offsetX: 10
offsetY: 10
color: Color.BLACK
radius: 10
}
}
I also enjoy JavaFX’s print/string format. Here is an example of combining it with “bind”. The code is so clean compared to doing to equivalent in Swing (or action/event based GUIs similar to Swing).
def totalValue: Text = Text {
font : Font {
size: 24
}
content: bind "Your Total Cash: ${totalCash}";
}
Although JavaFX is missing some key features such as interfaces and Threads, I still like it. It’s very effective for developing very nice RIAs. It loses strength when trying to developing a stateful game, but other than that I enjoyed the experience and look forward to working with it further.
curtiszerro.com LOL. Get to work, yo!
[Translate]