Monday, July 25, 2011

FlashPunk + Flixel = Flxpunk

Do you want to use the Flixel movement code at the FlashPunk project?

net.flxpunk package:

  • FlxEntity – Extends Entity class with Flixel movement code (velocity, acceleration, path, etc.)
  • FlxTween – Movement controller as a FlashPunk Tween extension
  • FlxPathFinding – Path finding stuff. Used Grid for a collision map.
  • FlxPath – This is a simple path data container.
...
// a collision grid
var grid:Grid = new Grid(720, 480, 24, 24);
grid.loadFromString(new LEVEL());
...
var pf:FlxPathFinding = new FlxPathFinding(grid);
var path:FlxPath= pf.findPath(unit.flx.getMidpoint(), new Point(mouseX, mouseY), true);
unit.flx.followPath(path, 60, FlxPath.PATH_FORWARD);
...

Github wiki
Download source code with example  

Read more: FlashPunk + Flixel = Flxpunk

Fast AS3 MultiMap

Sometimes you need to map a key to many values, but AS3 has no built-in data structure for this purpose. Dictionary and Object are suitable one-to-one maps, but there’s been no one-to-many support until now. Read on for my own one-to-many class—MultiMap—as well as performance testing and analysis. Before writing your own general-purpose class, it’s [...]

Read more: Fast AS3 MultiMap

Friday, July 22, 2011

Flash Game Dev Tip #10 – Flixels Internal Structure and Performance Tips

Flixels Internal Structure and Performance Tips

Tip #10 – Flixels Internal Structure and Performance Tips

If you’ve ever wondered just what Flixel does when it starts-up or runs its main loop, then wonder no more :) Here’s the full gory details, with some take-away performance tips at the end.

The Instantiation Process

All games in Flixel extend the FlxGame class, which in turn extends Sprite. When the game is created the following process happens, in the following order:

  1. It hides the system mouse cursor
  2. Calls FlxG.init which clears the bitmap cache, creates a new Sprite (flashGfxSprite) and creates an empty cameras Array
  3. Sets the internal game frame rate
  4. Sets the Flash Player frame rate
  5. Adds an ENTER_FRAME Event Listener which triggers FlxGame.create

Frame rates

Flixel 2.5 uses a Deterministic Delta Timer to handle steps within the framework. A step (as you’ll see later) is processed in the main loop, and is when Flixel performs all of the collision, separation and movement calculations. This is not the same thing as when it renders the game. When you create your game you have to tell FlxGame what game frame rate and Flash Player frame rates you want. From these two values it does the following:
  • Sets the step to be 1000 / Game Frame Rate. So a rate of 30 updates per second would equal a step of 33.
  • Sets the Maximum Accumulation (maxAcc) value to 2000 / Flash Player Frame Rate (fps) – 1.
  • So an fps rate of 30 would equal a maxAcc of 66. The maxAcc can never be less than step.
Read more: Flash Game Dev Tip #10 – Flixels Internal Structure and Performance Tips

Monday, July 18, 2011

Amazing Lookups Optimization

Today’s article is about an unintuitive-yet-simple optimization you can use to hugely increase the speed of reading from Array, Vector, Dictionary, Object, and dynamic classes. Need I say more? Read on for this amazing speedup! I was recently reading an article on Mark Knol’s site about some of the loop optimizations I’ve discussed before [...]

Read more: Amazing Lookups Optimization

Friday, July 15, 2011

Efficient Adobe Flash Professional using

Working with Adobe Flash Professional you should consider about performance and culture of the content you’re creating.
After some docs reading and co-workers listening, I came to this: I should collect and keep most common and useful “authoring-in-Flash Pro” rules in one place to help with efficient content creating. To make your knowledge of this topic even deeper – consider reading completely all links at the end of this post.
These rules will be useful for the Flash Animators and Flash Designers first of all, developers should know some rules too though.

Completely compatible with Flash Pro CS5.5 and not completely with earlier versions.

- Consider using as low frame rate as possible.
Most animations could be played smoothly enough at 24-30 fps. Graphics, like some application GUI without smooth animations could be played at 12 fps. If you wish to play smooth animation – you could change the fps with code. Using higher fps you’re giving Flash Player Runtime less time to draw, run code, GC. So, if given time will be too short to do all this for one frame, your animation will lose its smoothness.
Use 25 fps instead of 120 fps

- Avoid nesting when possible.
Use layers instead of containers (MovieClips) when possible. Decreasing amount of nested containers you’re increasing performance. [...]

Read more: Efficient Adobe Flash Professional using

Wednesday, July 13, 2011

We made 10 louder

There we are, after giving you access to some of the latest features coming in Flash through the Incubator program, I am happy to announce the availability of Flash Player 11 and AIR 3 in public beta (for desktop). You will find below the list of features available in this release. Please test your content against these builds, report any bug you find, log bugs, and if you want, you can also send me a message on Twitter (@thibault_imbert), I will follow up.

Some nice awaited community features are shipping here like removing BitmapData restrictions, Socket progress events, native JSON, etc but also other awaited features like native 64-bit support or Stage3D (aka Molehill). Of course we are working hard on mobile builds too, at this time the AIR 3 SDK is not available in a public beta; however you can apply for the private prerelease program here : https://www.adobe.com/cfusion/mmform/index.cfm?name=prerelease_interest

For those curious about why we do not provide yet 64-bit debugger builds, answer is : Flash Player is supported on 64-bit platforms for content playback. Given the architecture changes required for 64-bit debugging, support for content development will be made available in the next generation of Flash Platform tooling which is currently under development.

Finally, as 3D and security have been a topic of interest lately, Emmy Huang's is also giving some more details on her blog post about security and Stage3D (Molehill). Our statement below :

Because two of our primary design goals were to ensure Stage 3D will run great on mobile devices without compromising security, the Stage 3D implementation exposes a specific set of GPU features, resulting in a small API surface, making it easier to secure. We also added restrictions that help mitigate many of the security concerns around accessing OpenGL. For instance, we limit the number of calls per frame, minimizing the risk of denial-of-service attacks. We also designed a simple shader language (AGAL - Adobe Graphics Assembly Language) with restrictions such as prohibiting loops or functions inside shaders. The simplicity of AGAL makes it also easy to verify and validate compared to the GLSL dialect that is used by other solutions like WebGL.

Finally, I really want to emphasize that we are so excited about this release, we hope you guys will build amazing things with it, we had so much fun creating this, so enjoy!

New Features in Flash Player 11 and AIR 3 [...]

Read more: We made 10 louder.

Tuesday, July 12, 2011

Carve Up a Video in Real Time With AS3

Hello, code freaks! This tutorial will show you how to split a running video into blocks as if it has exploded. And all this using just ActionScript. For this tutorial we’ll use the camera as the video source, so you can see the changes live.


Final Result Preview

Let’s take a look at the final result we will be working towards:

Click and drag a block to move it around the screen! (Camera access required.)


Step 1: Setup – IDE

For this tutorial we’ll be using the FlashDevelop IDE (though you could use any AS3 editor). In case you don’t have it and want to try, you can grab it from >here. A basic tutorial on setting up FlashDevelop on you machine can be found here.

Also if you have Flash Professional installed on your side, that will work too. All you need to do is create an external class file as mentioned below and link it to your Flash project as a Document class.

Setup IDE

That sets up our working environment.


Step 2: Setup – New Project

Create a new AS3 project in FlashDevelop[...]

Carve Up a Video in Real Time With AS3

Monday, July 11, 2011

Using Playtomic Analytics In Your Flash Games

Playtomic Game Analytics and Services for Casual GamesPlaytomic is a free game analytics service I have been using in my Flash games for almost two years now. It provides a real time tracking platform not only for Flash games, but also for games made with HTML5, iOS, and Unity.

Playtomic is a great way to understand how playertesters are playing your games during the development phases of your game and then to further study how your game is being played and spread around the world once you release it.  Beyond the real time analytics tools it also offers global leaderboards, heatmaps, custom game data, and level sharing APIs.

I can’t recommend Playtomic enough as it has really had a large and beneficial impact on the way I approach my game development, playtesting, and publishing. I’m not the only one enjoying Playtomic either–over 2,000 developers are currently using the service to track over 3,000 individual games, and logging an amazing billion combined real time events per day!

Playtomic Analytics Tutorial Demo[...]

Using Playtomic Analytics In Your Flash Games

Even Faster Linked Lists

Linked lists can be much faster than AS3′s Array and Vector classes if you use them under the right circumstances. It’s been over a year and a half since I last visited the topic, but today it’s time to update my LinkedList class. Read on for the freshly-optimized code and all-new performance testing and analysis! [...]

Even Faster Linked Lists

Monday, July 4, 2011

Slicing, splitting and cutting objects with Box2D – part 3: cutting your own Sprites

In the second part of this series I showed you how to cut Box2D objects.

Unfortunately I was working in the debug draw environment, so the whole process can’t be applied in a real-world example, unless you want to publish a game with the debug draw graphics.

So it’s time to see how to cut your own sprites. This is what you’ll get at the end of this step:

Cut the debug draw polygons to see randomly colored debris fall down. These debris are Sprites generated in real time.

So let’s take a look at the source code, and see what changed since the previous step[...]

Slicing, splitting and cutting objects with Box2D – part 3: cutting your own Sprites