elsassph / nme-tilelayer

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

Size of TileClip #12

Closed JbIPS closed 11 years ago

JbIPS commented 11 years ago

Hi,

I'm using TileLayer for my UI elements and I've got some problems with the size of my TileClip. Here's my button in the Sparrow XML : <SubTexture name="continueButton.jpg" x="0" y="0" width="169" height="50"/> When I use it in my app and read its size I get width=253.5 and height=10024. His there a way to get the real size of the clip ?

elsassph commented 11 years ago

Which version of tilelayer are you using?

JbIPS commented 11 years ago

The last on haxelib: 0.2.7

elsassph commented 11 years ago

If you create a TileSprite/Clip, and if you added it to the layer, then the values should be correct. What target (html5/native/...)? Have an example?

JbIPS commented 11 years ago

I'm targeting Flash. Here an example for a button :

    var layer = new TileLayer(tilesheet);
    var upState = new TileSprite(tile);
    var downState = new TileSprite(tileDown);
    var overState = new TileSprite(tileOver);
    layer.addChild(upState);
    layer.addChild(downState);
    layer.addChild(overState);
    addChild(layer.view);
    layer.render();

This code gives you the result I described in my first comment. When I used Tab key, I saw the focus rectangle, and it was the size the debugger gave me.

elsassph commented 11 years ago

The size of layer.view is platform-dependent and will return unspecified results. Don't rely on it.

On Mon, Mar 11, 2013 at 4:00 PM, Jean-Baptiste Richardet < notifications@github.com> wrote:

I'm targeting Flash. Here an example for a button :

var layer = new TileLayer(tilesheet);
var upState = new TileSprite(tile);
var downState = new TileSprite(tileDown);
var overState = new TileSprite(tileOver);
layer.addChild(upState);
layer.addChild(downState);
layer.addChild(overState);
addChild(layer.view);
layer.render();

This code gives you the result I described in my first comment. When I used Tab key, I saw the focus rectangle, and it was the size the debugger gave me.

— Reply to this email directly or view it on GitHubhttps://github.com/elsassph/nme-tilelayer/issues/12#issuecomment-14717844 .

Philippe

JbIPS commented 11 years ago

Ok, that's the problem. Are the sizes of TileSprite and TileClip reliable ? Can I access them with the layer ? Thank you

elsassph commented 11 years ago

Size of TileGroup is not reliable.

TileSprite/Clip size is reliable. For TileLayer < 0.3 you must first addChild the Tile before reading their .width/.height.

On Mon, Mar 11, 2013 at 5:17 PM, Jean-Baptiste Richardet < notifications@github.com> wrote:

Ok, that's the problem. Are the sizes of TileSprite and TileClip reliable ? Can I access them with the layer ? Thank you

— Reply to this email directly or view it on GitHubhttps://github.com/elsassph/nme-tilelayer/issues/12#issuecomment-14722772 .

Philippe

JbIPS commented 11 years ago

Ok, thanks a lot !