tarnasm Posted November 2, 2016 Share Posted November 2, 2016 Hi, I have problem with collision in my simple platformer game. I have map loaded with a JSON file. My character collides only on the top of blocks. I attach my awful image bellow what simmulate my problem. (red lines simmulate's no collision area, on blue lines my player collides and stand into platform. var game = new Phaser.Game(640, 640, Phaser.CANVAS, 'main', { preload: preload, create: create, update: update, render: render }); var player ; var map; var layer; var key; function preload() { game.physics.startSystem(Phaser.Physics.ARCADE) game.load.tilemap('map', 'assets/map.json',null, Phaser.Tilemap.TILED_JSON); game.load.image('mainTileSet', 'assets/maps/tileSet.png'); // game.load.spritesheet('player', 'assets/sprites/tileSet.png',0,0); } function create() { map = game.add.tilemap('map'); map.addTilesetImage('mainTileSet'); map.setCollisionBetween(1, 180); layer = map.createLayer('mainLayer'); layer.resizeWorld(); layer.debug = true; player = game.add.sprite(0,0,'player'); game.physics.enable(player); game.camera.follow(player); player.body.collideWorldBounds = true; player.body.gravity.y = 600; key = game.input.keyboard.createCursorKeys(); } function update() { game.physics.arcade.collide(player, layer); if(key.left.isDown){ player.x -= 7 }if(key.right.isDown){ player.x += 7; }if(key.up.isDown){ player.y -= 15; }if(key.down.isDown){ player.y += 7; } } function render () { game.debug.body(player); } Link to comment Share on other sites More sharing options...
ionprodan Posted November 3, 2016 Share Posted November 3, 2016 Can you share all source code? I want to test and try to resolve your problem Link to comment Share on other sites More sharing options...
tarnasm Posted November 3, 2016 Author Share Posted November 3, 2016 You mean JSON map? Link to comment Share on other sites More sharing options...
tarnasm Posted November 3, 2016 Author Share Posted November 3, 2016 Any Solution to My problem? I really trying everything. Link to comment Share on other sites More sharing options...
Recommended Posts