Ninjadoodle Posted July 28, 2017 Share Posted July 28, 2017 Hi @enpu It's awesome to have you back! I'm using the develop version of Panda, and I was just wondering if it would be possible to calculate the offset when repositioning containers automatically. I'm not really sure if this is possible, but basically if I want to centre my container while using the 'resize' setting - I have to manually calculate the offset from the original (0, 0). Just wondering if an automatic solution is doable. Thank you heaps in advance! Quote Link to comment Share on other sites More sharing options...
enpu Posted July 28, 2017 Share Posted July 28, 2017 I'm not exactly sure what you mean, if you want to centre something you usually use game.width and game.height values, and those will change if you use resize setting. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 28, 2017 Author Share Posted July 28, 2017 Hi @enpu I think it might be too difficult. Just to give a bit more detail ... I'd like to to show more of the stage while having the game centered. Currently when using resize, it put the game in the upper left corner (0, 0). It would be very cool if the game was entered instead (maybe an extra / new setting - SHOW OUTER?). I know this can be done with a container, but then the coordinates are also shifted and I need to calculate an offset from (0, 0). So lets say I have a 640x640 game. The game would be centered in the middle of the screen with more of the stage showing to the left and right BUT the coordinates to the left would be negative. Basically this would be exactly the same as when you use 'centre', but with showing more of the stage on the sides and top/bottom. Hope this explains it better PS. I know you had a donation / tip jar in the past - but I can't seem to find it, in case I wanted to send some coffee/beer money through lol Quote Link to comment Share on other sites More sharing options...
enpu Posted July 28, 2017 Share Posted July 28, 2017 Not sure if i still understand correctly Yes the position (0, 0) is always the left top corner. So you want the (0, 0) position to be center of the stage? Simplest way would be to create container and put everything inside that container and then place it at the center of the stage. Then position (0, 0) inside the container would be center. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 28, 2017 Author Share Posted July 28, 2017 Hi @enpu I've updated the post above - I think what I was asking about was basically a 'centre' setting that shows more of the stage on the sides and top/bottom. I'm pretty sure that last time I've used Panda - containers didn't have their own co-ordinates. I must give it a go and see Thanks for trying to understand my confusing question! Quote Link to comment Share on other sites More sharing options...
enpu Posted July 28, 2017 Share Posted July 28, 2017 Yes containers have coordinates and always have had as far as i can remember. Try this if you want it like in that image: var container = new game.Container(); container.position.x = game.width / 2 - 640 / 2; container.position.y = game.height / 2 - 640 / 2; container.addTo(this.stage); var sprite = new game.Sprite('player.png'); sprite.addTo(container); Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 28, 2017 Author Share Posted July 28, 2017 I think I got it! Thanks heaps for your help - I think I've gone braindead for a moment there lol. 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.