Sign in to follow this  
Ninjadoodle

"Resize" offset question - SOLVED

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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

Diagram.png

Share this post


Link to post
Share on other sites

Not sure if i still understand correctly :D

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.