julacariote Posted April 11, 2014 Share Posted April 11, 2014 Hello, If I flip a sprite on the horizontal axis, meaning I set its scale to (-1, 1), the width of the sprite become negative because the width is defined like this in Sprite:Object.defineProperty(PIXI.Sprite.prototype, 'width', { get: function() { return this.scale.x * this.texture.frame.width;});This makes perfect sense if I scale my sprite to for example (0.5, 1), its resulting width would indeed be the half of the original size. But in the case of flipping a sprite, why not returns the absolute value to always get a positive width? I guess this is done this way on purpose, I'm just wondering why a width should be negative? Quote Link to comment Share on other sites More sharing options...
2dt Posted April 12, 2014 Share Posted April 12, 2014 Interesting catch. I also think width should return the absolute value. EDIT: Now that I think about it, the negative width would probably make it more intuitive to calculate the visual bounding box of a sprite. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.