December 11, 2009 on 11:24 pm | In Miscellaneous | 7 Comments
After a long silence it’s time to update my blog again. So what happened? I moved from AS3 to HaXe and actually published my first flash game written in HaXe. This was a very ambitious job and virtually took all my time because in addition to a very tight deadline I had to port my AS3 libraries to HaXe.
By the time the game was finished I started to work on a single open source library called polygonal as a replacement for the as3ds and motor2 project. The latter simply became unmanageable as it was using many other small libraries – so it made sense to bundle everything and provide a single out of the box solution, rather than creating a bunch of small projects.
Meanwhile, the polygonal project is hosted here: http://code.google.com/p/polygonal/
The next task is to update the physics engine so it compiles against the new library.
April 26, 2009 on 1:00 pm | In Actionscript, Miscellaneous | 47 Comments
Working with text in Flash can be a painstaking procedure, especially if you just want to quickly draw and animate some simple characters on screen using ActionScript. It usually takes many lines of codes to setup and adjust the appearance and alignment of text fields and you need to take care of other little annoying details like the whole font embedding procedure.
Lately I was working on a new interactive testbed for the motor physics engine where I’m solely using the new flash player 10 vector drawing API, but I needed to add some text. I was curious about how hard it would be to add text rendering capabilities to the drawing API and after some investigation I found an easy way using an old copy of Fontographer to extract the necessary data from a true type font file (much easier than trying to parse a .ttf file directly):
- Export the font data as an EPS postscript file.
- Write a parser to transform each glyph into a bunch of lineTo, moveTo and curveTo commands.
- Export and parse the spacing and kerning table (proportional fonts only).
- Write a method for drawing cubic bézier curves.
Following these steps I ended up with a simple text rendering engine. Here my result:
Monospace/Proportional font rendering (Consolas/Arial)
As you see small font sizes won’t be that sharp and readable as a TextField set to “Anti-alias for readability” but on the other hand the results are very smooth and perfect for animation. Placing and aligning text blocks is also much easier since it’s straightforward to compute bounding boxes for glyphs and text blocks.
So now drawing a text is a matter of writing:
...
graphics.beginFill(0, 1);
new Arial(10.0).print("Hello World", 100, 100);
graphics.endFill();
...
This will draw “Hello World” at x,y=100,100 and a font size of 10 points. KISS!
An exciting thing is that the FP10 drawing API is actually very fast; the following demo scrolls all ASCII characters back and forth. Press space to toggle between regular text field and vector rendering. In the first case a TextField object is created once and then moved by adjusting its position, whereas in the second case the whole text is redrawn in every frame at a new position:
TextField vs. Graphics
If (hopefully) more people besides me find this useful I would invest some extra time to polish the code and publish it as open source. It made my coding life simpler :-)
March 9, 2009 on 3:53 pm | In Actionscript, Miscellaneous | 4 Comments
haXe is fantastic! The language has some very nice features like type inference which I don’t want to miss anymore. Even better, the compiler is lightning fast and will provide you almost instantly with compiler errors, so fixing your code becomes a short and sweet procedure. There are also libraries available for writing ABC byte code or PixelBender assembler directly in haXe. Isn’t that nice ?
The only problem right now is the lack of a full blown IDE for haXe. I love FlashDevelop and use it every day. Unfortunately the auto completion for haXe in FD3 is somewhat in an experimental stage and goes crazy for classes with type parameters. Hopefully this will be improved in a future release. But otherwise the work flow is very nice and I’m currently porting my open-source libraries to haXe.
November 20, 2007 on 2:34 pm | In Miscellaneous, Physics | 15 Comments
Someone made a direct port of the great Box2D physics library from C++ to AS3 called Box2DFlashAS3. Because the physics solver of the motor engine is based on Box2D Light and the version I’m currently developing follows the Box2D engine framework closely I’m feeling a little redundant with my project now. Anyway I’ll continue development but there isn’t really a reason to wait for my release since Box2D is simply the best!
May 25, 2007 on 11:08 am | In Links, Miscellaneous | No Comments
Mika from flashdevelop.org: “Here’s a release that lots of people have been waiting for, FlashDevelop 3. This is an alpha release that may contain bugs or may lack some features but we wanted to start the release cycle for our new baby. We hope you like it.”
Hell yes, I love it! I also tried Flex Builder, but I prefer using FlashDevelop because it’s free, fast and has everything I need for Flash development. The only thing I’m missing is a built-in debugger, but as I understood the guys are also working on it.
More information: http://www.flashdevelop.org/community/viewtopic.php?t=1436