StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
285 stars 88 forks source link

Setting "y" of Shape also updates it's "height" property #29

Closed neolit123 closed 11 years ago

neolit123 commented 11 years ago

hello,

i'm not sure if this is specific to the graphics extension or this is a starling bug, but this snippet produces a "y" dependent "height" out of the Shape class:

var shape:Shape = new Shape();
shape.graphics.beginFill(0);
shape.graphics.drawRect(0, 0, 100, 100);
shape.graphics.endFill();
cont.addChild(shape);
trace(shape.width, shape.height); // 100, 100
shape.x = 400;
shape.y = 200;
trace(shape.width, shape.height); // 100, 300

so the formula for "height" becomes: height = "real graphics height" + x - y

an override in Shape for "get height()" is obvious, but does anyone have any idea why this actually happens?

thanks for any insights

neolit123 commented 11 years ago

here is the "naive" solution i mention above:

// Shape.as
override public function get height():Number
{
    if (super.x > super.y)
        return super.height + super.x - super.y;
    return super.height;
}
jonathanrpace commented 11 years ago

Could you check if this is still the case after getting this commit? https://github.com/unwrong/Starling-Extension-Graphics/commit/6e10dace1df6a092c9812fdd44739bde64b15060

neolit123 commented 11 years ago

just noticed the "y" typo myself and was about to send a PR. thanks for the quick fix and the nice extension. :)

will report if i find other small issues.

robsilv commented 11 years ago

Cool, glad it's working for both of us! :-)