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

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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