I’ve read up on Tileset and Tiles and have a pretty good idea how they work at the top level.
I was wondering if, for non-Flash targets, using a bitmap/texture atlas + *.graphics.beginBitmapFill + *.graphics.drawRect would offer similar performance and draw call count? Or is this a process that is further optimized by using Tileset?
As long as you have only one bitmap (and I do mean bitmap. Not bitmapdata) you should get good performance.
Keep in mind that every bitmap object will render itself and will not batch with other bitmap objects even if they use the same texture.
That means you sacrifice the goodness of the display list father-child relationships.
The advantages of tiles is having multiple objects that share a texture and batch render and can use the display list concepts of father-child (with tilecontainer being analogue to Sprite and Tiles to Bitmaps)
I think that the idea of selecting a texture and drawing rects (or quads ) is how flixel does things.
Let’s say I have an atlas in a single .png file and I load said file in a BitmapData object.
Now, I create a Sprite called “bob” and do a bob.graphics.beginBitmapFill and then a bob.graphics.drawRect.
Ok, that is boring, I need another thing on screen. Let’s say I create another Sprite called sally and do the same thing, sally.graphics.beginBitmapFill and sally.graphics.drawRect with the exact same BitmapData that I used for bob.
sally and bob will not be batch rendered. They are in 2 different DisplayObject and each DisplayObject will take one draw call minimum.
The way to get performance would be to create a Sprite called “friends” and do something like
friends.graphics.beginBitmapFill(<Matrix data for bob here>);
friends.graphics.drawRect(<where you need to draw bob>);
friends.graphics.beginBitmapFill(<Matrix data for sally here>);
friends.graphics.drawRect(<where you need to draw sally>);
You can take a look on my code. It uses drawTriangles instead of drawQuads. The library is called AtlasTriangle and uses atlas packed with polygon instead of tiles.