Hi.
So, I have the habit to draw my tilesheets are runtime, to make them perfect for the resolution available.
It can be tricky at some times, but I am always satisfied by the pixel perfect result.
And it’s okay when you only have to run it once, store the texture on the device, and move along.
But with multi windows systems on Android and iOS becoming a thins, and the porting of android apps to Chrome and other devices, the size of the app can change, sometimes while playing.
So rather than blocking the thread for 2/3 seconds, I would rather do it on a secondary thread.
And it works fine, as long as you only work with bitmaps, you can pass them without any issue frome the main thread to another.
But trying to use Bitmap.draw, with a vectorial shape as the item to draw, fails.
I tried creating a sprite or passing is as parameter, and it fails both times.
The sprite to draw and the bitmapData both just fill in black.
Here is the test class file I used:
http://pastebin.com/zAGC6pyr
I simply call it like that from the main class constructor:
var stamp:Sprite;
stamp = new Sprite();
stamp.x = 20;
stamp.y = 20;
addChild( stamp );
var sprite:Sprite;
sprite = new Sprite();
sprite.x = 40;
sprite.y = 20;
addChild( sprite );
var cacher:Cacher = new Cacher( sprite.graphics, stamp, 256, 256, 10 );
And as I said, if I choose ( at line 138 ) to just draw in the bitmapData using fill rect, I see that everything works fine.
I can draw to a sprite added to the main view, it will display fine, and when I get the shared bitmapData back, it displays fine.
But if I choose to draw the sprite to the bitmap, both become black:
What is weird is that the sprite becomes black even before BitmapData.draw is called ( I checked by putting a 2 seconds sleep on the thread ).
So, I have no clue what more I can try.
Ok, I know. This is a specific usecase.
Definitely not a priority.
But is there a way to make it work, by initializing something in the new thread or something, that would be great.