I am trying to learn how to use OpenFL’s Tilesheet. So far, I am able to render images using the TILE_TRANS_2X2 flag, so I have scaling and rotation covered. However, when I try to use the TILE_ALPHA or TILE_RGB flags, they seem to have no effect on my tiles.
The problem persists on OpenFL 2.1.6, 2.1.7 and 2.2.1 along with Lime 2.0.1 and 2.0.4. I am able to display sprites using HaxeFlixel using these versions, however, so there must be something wrong with my usage of Tilesheet.
Are there any additional setup code or settings I need in order to enable TILE_ALPHA or TILE_RGB? Here is the code I am using at the moment (just with TILE_ALPHA):
var sprite = new Sprite(); addChild(sprite); var bitmapData = Assets.getBitmapData("assets/img/troll.png"); var tilesheet = new Tilesheet(bitmapData); tilesheet.addTileRect(new Rectangle(0, 0, 29, 29)); var data:Array<Float> = [ // x, y, tileID, alpha // Tile 1 1, 1, 0, 1 // Tile 2 31, 1, 0, 0.5 // Tile 3 61, 1, 0, 0.25 ]; tilesheet.drawTiles(sprite.graphics, data, false, Tilesheet.TILE_ALPHA);
As you can see, I am only trying to render three tiles with varying alpha values, and yet I see no difference in the output. This is what I get:
Is there something missing from my code, or am I doing something wrong? Is there any setting I need in the project XML file to make sure TILE_ALPHA and TILE_RGB will work?
It appears that TILE_ALPHA only fails to work on Flash. I built my project for Windows, HTML5 and Android, and in all cases TILE_ALPHA worked as expected.
Here is the result on Windows:
Is Tilesheet hobbled on Flash or something?
I did some more tests and here are the results:
- Windows and Android - TILE_ROTATION, TILE_SCALE, TILE_RGB, TILE_ALPHA all seem to work
- HTML5 - TILE_COLOR does not work, while TILE_ROTATION, TILE_SCALE and TILE_ALPHA seem to work.
- Flash - TILE_COLOR and TILE_ALPHA do not work. TILE_ROTATION behaves differently from other platforms.
Should I steer clear of Tilesheet when in need of cross-platform rendering?