Home >
5 Things I Learned from Flixel

Advanced Flash Tactics or AFTs are techniques that come from deep within the Flash Art Of War, the oldest Flash military treatise in the world. In this AFT I will go over - 5 Things I Learned from Flixel. Flixel is a framework for creating bitmap (8-bit and 16-bit like) games. I have always been fascinated with making games with Flash but over the years never really got anywhere with it. So the other day I decided to check out the Flixel Framework and here are a few things I learned:
Use Of Singleton
I really like Flixel’s use of Singletons (more like static classes). At first I was totally turned off to the idea of it in Flixel due to the OOP community’s brainwashing against using Singletons but in games they make total sense. At the core of the framework is a class called FlxG. This class manages useful functions for audio, input, basic info, and the camera system among other things. Having it accessible at any point in the game is a big boon and I don’t worry about the speed impact of using a binding system or events.

State
States represent what you would consider a scene. Welcome screens, settings windows, game levels, and game over screens are all states. The core FlxGame class is locked down and instead you are encouraged to extend the FlxState class. This class has logic for creation, pre-process, collide and render. States are incredibly powerful and allow you to separate state logic from the main application. Whatever state is active has the full attention of Flixel’s render. Changing state is also very easy; simply pass in a new State instance to FlxG.state. I couldn’t have imagined a cleaner, more performance oriented approach.
Sprites For Animation
Flixel uses a clever system for animating game characters from sprite sheets. Simply create a series of images in a row (horizontally) then define the width of each frame of the sprite sheet. Flixel automatically cycles through the strip of sprites. This is great because you don’t have to worry about defining each step of the animation. Of course you have to use sprites that are the same size or it will not work. The FlxSprite class allows you to register your own animation states along with settings defining if it should loop or not. This keeps the system incredibly flexible and easy to use.
Clean, Focused, and Precise
Everything in the Flixel framework has a very focused purpose. There is little “filler” in here. One of the most impressive systems is the global render cycle. This helps unify all the view render logic and creates a predictable, fps independent game loop. I have always been fascinated with game loops and use them in a lot of my own code. Also because the entire framework runs around this loop you always have a central point where you can inject contextual game logic.
Runs great on Android
Perhaps one of the most exciting things I discovered while playing with Flixel is how it runs on Air on Android. I was getting a smooth 30 fps with the online demos. I haven’t done much testing with movement or scrolling (since there is no built in support for touch devices) but if the demos are any indication of what is possible with Flixel on Android then I imagine the framework playing a supporting role in Flash Mobile Gaming.
This is a demo from the Flixel game framework running on a Nexus One in AIR.
Conclusion
So this is just the tip of the Flixel iceberg. There are so many good code gems in the framework that I suggest you take some time to go through it. I leaned most of what I know when I built and studied gaming in Flash. Even now I still play with game logic in my free time (such as my attempt to build a Flash Rogue game) and have taken advantage of Tile engines, sprites, and game loops in most of my code I build today.
- FITC Day 3 - Afternoon: Ralph Hauwert (take 2), Theo Watson and Emily Gobeille, Brendan Dawes and Yugo Nakamura
- FITC Day 3 - Morning: Kristin Henry, Grant Skinner and Jeremy Thorpe
- FITC Day 2 - Afternoon / Evening: Jared Ficklin, Eric Natzke and Robert Hodgin
- FITC 2 - Morning: Ralph Hauwert, Jim Corbett and Joa Ebert
- Introducing tinytlf




Facebook Application Development
Good! Thanks for introducing a good flash game engine! And waiting for your tutorials for flixel. Really want to know how it works, and how do I use it in my game? Have a nice day. :)