Jump to content

Collision stops


Recommended Posts

Hi, I'm building a game in Phaser but I came along a strange bug. Whenever I'm testing the game and I open the developers tools (or another action like 'right click > copy image'), my character stops colliding with the tile map. This also seems to happen sometimes when I change the desktop on my mac. I searched a long time but can't seem to fix it. Any ideas?

Here is my code:

var mainState = {	preload: function(){		game.load.tilemap('map','assets/tilemap.json', null, Phaser.Tilemap.TILED_JSON);		game.load.image('tileset','assets/tileset.png');		game.load.atlas( 'atlas', 'assets/atlas_char.png', 'assets/atlas_char.json' );	},	create: function(){		game.physics.startSystem(Phaser.Physics.ARCADE);		game.stage.backgroundColor = '#dadada';		game.world.bounds.setTo(0,0,1200,800);			this.player = game.add.sprite(45,670,'atlas');		game.physics.arcade.enable(this.player);		this.player.body.collideWorldBounds = true;		this.player.body.gravity.y = 250;				this.createWorld();		game.camera.follow(this.player);		this.cursor = game.input.keyboard.createCursorKeys();		game.input.keyboard.addKeyCapture([Phaser.Keyboard.UP, Phaser.Keyboard.DOWN, Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT]);	},	update: function(){		game.physics.arcade.collide(this.player, this.layer);	},	createWorld: function(){		this.map = game.add.tilemap('map');		this.map.addTilesetImage('tileset');		this.map.setCollision(1);		this.layer = this.map.createLayer('Tile Layer 1');				this.layer.debug = true;		this.layer.resizeWorld();	}};var game = new Phaser.Game(800, 500, Phaser.CANVAS, 'gameDiv');game.state.add('main',mainState);game.state.start('main'); 
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...