Jump to content

Offset game screen


Sturb
 Share

Recommended Posts

Hey guys, I'm not sure if this is a canvas or scale manager things but what I trying to achieve is some way to offset the game screen after scaling it.

I need to support 16:9 and 4:3 aspect ratios. I have the scaling part all done and working, my issue is that I need to apply my calculated offsets to the game screen so the left and right edges are pushed out of view when in a 4:3 ratio.

 

This is what I'm currently getting when in 4:3. The darker areas would be out of view, or off screen.

wrong.png

 

This is what I'm looking to achieve when in 4:3. The darker areas would be out of view, or off screen.

right.png
 

Any help would be appreciated :)

Link to comment
Share on other sites

Hi, I found very beneficial to set 0,0 in the middle of the screen in my games:

            // set camera
            this.world.setBounds(-this.game.width / 2, -this.game.height / 2, this.game.width, this.game.height);
            this.camera.focusOnXY(0, 0);
  1. all objects are then placed relative to 0,0,
  2. when scaling, center remains in center.

There are games where I am setting center point at different places - I was working on game, where objects are falling down (kind of tetris / match-3) and there it was advantageous to place 0,0 at bottom center. But setting center where I need it is key for me.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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