shabeerahmedshah Posted March 31, 2016 Share Posted March 31, 2016 Is it possible in pixi.js to scale the stage from the very center of the stage as there is no anchor available in it. What I basically need is to focus on an object whose position will be canvas centered and its size will always be less the canvas size but it should be zoom-able with the mouse scroll. Quote Link to comment Share on other sites More sharing options...
Exca Posted March 31, 2016 Share Posted March 31, 2016 You can use pivot. container.pivot.x = Math.round(canvassize.width/2); container.pivot.y = Math.round(canvassize.height/2); Quote Link to comment Share on other sites More sharing options...
shabeerahmedshah Posted March 31, 2016 Author Share Posted March 31, 2016 Using this hides the half of the stage's area to the left. Quote Link to comment Share on other sites More sharing options...
shabeerahmedshah Posted March 31, 2016 Author Share Posted March 31, 2016 Seems, it would work if we change its position. Quote Link to comment Share on other sites More sharing options...
fire7side Posted March 31, 2016 Share Posted March 31, 2016 Your container wasn't the size of the canvas. You need the formula he gave, but using the container width and height, not the canvas. I think. I haven't used the pivot. It just looks that way. I think Ivan answered on the redundant thread and you better use that. I haven't used it. Quote Link to comment Share on other sites More sharing options...
Exca Posted April 1, 2016 Share Posted April 1, 2016 Oh yeah, sorry I misunderstood. This will fix that: container.pivot.x = container.width/2; container.pivot.y = container.height/2; container.x = canvassize.width/2; container.y = canvassize.height/2; Adding rounding to those values will prevent some blurrines if the sizes are not dividable by 2. If your container is scaled then you need to get the real dimensions of the container (either set the scales to 1,1 or use getLocalBounds). 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.