Muhammad Adnan Posted December 15, 2017 Share Posted December 15, 2017 Hey everyone, I want to center an element (in this case a graphics element) in the center of the screen. https://jsfiddle.net/user/adnanchang/fiddles/ As you can see from my code, I am changing the position of the graphics and bringing it to the center of the screen. I don't want that. I want to actually move the pivot/position of the stage in such a manner that the graphics then looks like it is to the center of the screen. Also, would it be possible to save the original position of the stage? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 15, 2017 Share Posted December 15, 2017 Everything is possible, its just you need to wait for another helper, other than me I just dont want to give you more code unless you figure out some stuff for yourself, from my point of view, you already have everything to figure out the solution. Muhammad Adnan 1 Quote Link to comment Share on other sites More sharing options...
Exca Posted December 15, 2017 Share Posted December 15, 2017 You could just say stage.x = renderer.width/2 and stage.y = renderer.height/2. Then your stage is in center and everything under it is rendered in relation to the stage. Though I would suggest keeping the stage in 0,0 and create another container which you move to center and have graphics added under that. Makes it a lot easier to implent overlay ui for example when you dont have to do inverse calculations to get items where you want. ivan.popelyshev and Muhammad Adnan 2 Quote Link to comment Share on other sites More sharing options...
Muhammad Adnan Posted December 18, 2017 Author Share Posted December 18, 2017 Thank you guys, I am amidst of applying multiple executions in order to understand position, pivot, offset and how they affect children and themselves. I am also trying to get a flavor or "LocalBounds' so I understand the relativity of positioning etc. I'll post soon with what I achieve. ivan.popelyshev 1 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.