LameLemon

Black bar appearing at the top and rightside of canvas

Recommended Posts

I've used a Tiled Map with my project before and it worked perfect, however the second map I made has a black bar on the right and top. I can move into the black space but the Camera will not allow me to move left off screen.

My canvas is set to this resoltuion

var game = new Phaser.Game(640, 480, null, 'gameDiv');

This is how I load my assets

  preload: function() {

    game.stage.backgroundColor = '#000000';

    game.load.tilemap('level0', 'assets/map/Level0.json', null, Phaser.Tilemap.TILED_JSON);
    game.load.image('tiles0', 'assets/map/[TILESET]Dirt-City.png');
  }

 

This is the code in my play.js create function.

    
    create: function () {    
          var map = game.add.tilemap('level0');
          map.addTilesetImage('[TILESET]Country', 'tiles0');
          this.layer = map.createLayer('Tile Layer 1');
          game.world.setBounds(0, 0, 640, 4800);

          this.player = new Player(300, 4700);
    }

My camera updates it's location based on that of the player like so

  player.update = function() {
    game.camera.x = this.x - 150;
    game.camera.y = this.y - 300;
 }

 

 

I have been trying to figure out this problem for quite some time, any help is greatly appreciated. Thank you.

Screenshot-2018-3-11 CodeFarmer(1).png

Screenshot-2018-3-11 CodeFarmer.png

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.