Posted on Feb 20, 2011

Flash to Unity, part 2

In 2010 I’ve put aside my Flash project for a more ambitious one in partnership with the University of Québec in Abitibi-Témiscamingue and the Cirque du Soleil. Pulsions was an experiment with different new technologies like stereoscopic 3d-rear-projected, tracking devices and architectural projection. Our team built a 2d animation and a 3d-stereoscopic one with 3ds Max and played in real time with Max MSP. I built 5 interactive projections with IR tracking that were all networked, creating a whirl of particles across the show room. Built using Java, OpenGL and OpenAL, it was very interesting to play with something else than Adobe Flash – in fact, it was pretty amazing.

How Flash’s AS3 compare to Java + OpenGL? It’s like racing with a bike against a formula 1. Flash doesn’t render with the GPU, everything is ran on the CPU, and that’s a lot - game-loop, render, sound, networking, loading, input, etc. Adobe announced their project named Molehill, a GPU API for rendering 2D/3D. Anyway, the workflow between Flash and OpenGL is too different; Flash abstracts everything for the programmer. How we suppose to “port” a game using Flash to mobile? Yeah sure Adobe is pushing hard on “Flash everywhere” but I can tell you that my experiments run poorly on my Samsung Galaxy S. So it was time for me to understand low-level display.

I tried to understand what was all the fuzz around framework like Flixel and Flash Punk by creating my own. By not using any of the Flash built-in objects, I was able to understand basic 2D display and collisions.

Bitmap engine and P2P

Fexel v0.1 features :

  • Bitmap drawing without transformation;
  • Spritesheet, Animated Spritesheet, Tiling, Text, etc;
  • SAT collisions for polygons, circles;
  • P2P using Adobe Cirrus;

It took me 5 months of spare time to build, but I’ve learned so much in the process. Runs smooth but it’s very limited: no transformation, collisions are slow (cannot have more than 10 dynamics object on stage). Rewrite had to be done to add transformation, so I did. But I’ve also decided to give Box2D a try – much more reliable that my piece of code. 3 weeks later, here the result.

Fexel with Box2d

Fexel v0.2 features:

  • Bitmap drawing with transformation;
  • Bitmap, Text, Vectors (rasterized), Spritesheet, Animated Spritesheet, Tiled Bitmap;
  • Cameras;
  • P2P;
  • Collisions mechanic independent.

If you look at my code and code of EaselJS project, by gSkinner, you will see that it is very similar. I’m saying that because gSkinner’s work was always an inspiration and I’m proud to see that my reasoning was the same without knowing it.  Performance wise, it’s still running like crap on my Android. Yeah I could put it in AIR package to see if it runs better, but I wont bother. There must be a way to develop for multi-screen and still get decent performance?

In the part 3 of this serie, I’ll discuss how I found my way into Unity 3D.

Latest Tweets