Jump to content

Positioning Background Image on Canvas Correctly


lifesuxtr
 Share

Recommended Posts

Hi guys i am trying to load a background image on canvas and position game camera on certain position and zoom level.

This is the example background image:

http://i.hizliresim.com/3zYlaA.png

When i load the image it looks like this:

ED5AgB.png

 

 

I want to set position of background image (or camera ? )like this:

4zbVMq.png

Canvas is 800x600

const preload = () => {
  
  game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

  game.load.image("background", "http://i.hizliresim.com/3zYlaA.png")

};

const create = () => {
  cursors = game.input.keyboard.createCursorKeys();

   background = game.add.tileSprite(0, 0, 800, 600, 'background');
    //  Creates a layer from the World1 layer in the map data.
    //  A Layer is effectively like a Phaser.Sprite, so is added to the display list.


}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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