Jump to content

Phaser arcade collision detection with tiled.


Recommended Posts

Im having a problem here. I can't seem to get a tiled map to work with arcade collision detection. Any help on this matter would be great. Thanks.



function create() {    game.physics.startSystem(Phaser.Physics.ARCADE);        mymap = game.add.tilemap('devmap01');    mymap.addTilesetImage('MyTheme');        backgroundLayer = mymap.createLayer('Background');    blockedLayer = mymap.createLayer('Collision');        mymap.setCollisionBetween(1, 100000, true, 'Collision');        backgroundLayer.resizeWorld();        player = new Player(game);    game.physics.enable(player.sprite, Phaser.Physics.ARCADE);        game.world.setBounds(0, 0, mymap.widthInPixels, mymap.heightInPixels);    cursors = game.input.keyboard.createCursorKeys();    game.camera.follow(player.sprite);}function update() {    game.physics.arcade.collide(player, blockedLayer);    player.update(cursors);}
Link to comment
Share on other sites

game.physics.arcade.collide(player.sprite, blockedLayer);

So I found this issue before my post was approved unfortunately. There were two problems, one the problem you specified drhayes(thanks btw) and the second was that my collision layer was not on the bottom in tiled.

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...