Jump to content

"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!

Link to comment
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


Link to comment
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.

Link to comment
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!

Link to comment
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;

var sprite = new game.Sprite('player.png');


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...