ptol Posted March 22, 2016 Share Posted March 22, 2016 With sprite it's possible to use anchor, but container only has pivot. So I wrote something like this. Is it a correct approach? The only disadvantage is I need to update it after any bounds changes, is there any simple way to improve it? var px = PIXI; Object.defineProperty(px.Container.prototype, "pivotAnchor", { get: function() { var bounds = this.getLocalBounds(); var x = 0; var y = 0; if(bounds.width > 0){ x = this.pivot.x/bounds.width; } if(bounds.height > 0){ y = this.pivot.y/bounds.height; } return new px.Point(x,y); }, set: function(v){ var bounds = this.getLocalBounds(); this.pivot.x = bounds.width*v.x; this.pivot.y = bounds.height*v.y; }}); container.pivotAnchor = new px.Point(0.5, 0.5); l Giedrius 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 22, 2016 Share Posted March 22, 2016 That's the only way to do that, and that's why containers dont have anchors 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.