elsassph / nme-tilelayer

Lightweight wrapper over NME's powerful but lowlevel 'drawTiles', with bitmap-based fallback for Flash.
92 stars 11 forks source link

TileSprite.width is zero in JS #14

Closed JbIPS closed 11 years ago

JbIPS commented 11 years ago

Hi, I'm trying to extract a bitmapData from a layer by drawing a rendered TileSprite in a BitmapData. Here's my code :

var tmpLayer = new TileLayer(tilesheet);
var tile = new TileSprite(tmpLayer, tileId);
tmpLayer.addChild(tile);
tmpLayer.render();
var bmpData = new BitmapData(Math.round(tile.width), Math.round(tile.height), true, 0);
var tmpSprite = new Sprite();
tmpSprite.addChild(tmpLayer.view);
bmpData.draw(tmpSprite);


This works fine for Flash target. The problem is tile.width and tile.height are equal to zero when I target HTML5. The layer and the tilesheet are ok (normal size, defs are here) but there seems to be a problem with the TileSprite.

I'm using OpenFL 1.0.6 and the TileLayer library on haxelib (0.0.1)

elsassph commented 11 years ago

You should upgrade tilelayer, it's version 0.4 on haxelib now and the size is correctly reported for me.

elsassph commented 11 years ago

Oh 0.0.1? maybe that's the OpenFL version? https://github.com/matthewswallace/openfl-tilelayer I don't see the bug in this version either - is the tileId valid?

JbIPS commented 11 years ago

Yes it is the OpenFL version and it's all my fault, files got mixed up between Flash and HTML export, so it was the wrong Tilesheet in HTML with the good tileId. So nevermind, and thanks for the hint!