TallDrink Posted July 29, 2018 Share Posted July 29, 2018 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 More sharing options...
samme Posted July 29, 2018 Share Posted July 29, 2018 You need to add a collision check in update(). TallDrink 1 Link to comment Share on other sites More sharing options...
TallDrink Posted July 29, 2018 Author Share Posted July 29, 2018 It's always something small like that, isn't it? Thank you! If I have additional questions is it fine to just keep them to this thread? Link to comment Share on other sites More sharing options...
TallDrink Posted July 30, 2018 Author Share Posted July 30, 2018 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 More sharing options...
Recommended Posts