Jump to content

Tilemap not properly colliding


TallDrink
 Share

Recommended Posts

I haven't been able to get my player sprite to collide with my tilemap.

I have been relying on the learning examples to figure out implementation, but some things are unclear and I have not been able to find an answer in the reference manual. Below is a code snippet that may have the main issue and at the end of the page I have included a zip file if anyone wanted to dig deeper:

	map = game.add.tilemap('map', 100, 100);
	
	map.addTilesetImage('ground');
	
	map.setCollisionBetween(0, 100);
	
	layer = map.createLayer(0);
	
	layer.resizeWorld();
	
	//layer.debug = true;
	
	game.physics.startSystem(Phaser.Physics.ARCADE);
	
	//game.world.setBounds(0,0,750,750);
	game.add.sprite(500,500, 'hp');
	game.physics.startSystem(Phaser.Physics.ARCADE);
	game.physics.arcade.gravity.y = 300;
	
	player = game.add.sprite(100, 100, 'player');
	game.physics.enable(player, Phaser.Physics.ARCADE);
	
	player.enableBody = true;
	
	player.body.collideWorldBounds =  true;
	//player.physicsBodyType = Phaser.Physics.ARCADE;
	cursors = game.input.keyboard.createCursorKeys();
	
	player.body.gravity.y = 1000;
	player.body.maxVelocity.y = 500;
	player.body.setSize(20,32,5,16);

	player.body.setSize(100, 100, 0, 0);

	player.body.collideWorldBounds = true;

I would appreciate any.

 

myGame - Copy.rar

Link to comment
Share on other sites

Is there anyway to add multiple tilemaps to a single room? I am trying to get to a point where I can create four quadrants in the map and then randomly select four to create a level, but I am struggling to find out how to load in multiple tilemaps.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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