Jump to content

TileMap Collision not working with Tiled


Zendrael
 Share

Recommended Posts

Hello all!

 

Well, after about 8 hours on this I have to say that I really don't know what is happening... The collision simply is not working. All shows ok but not colliding... Here is my code so far:

create : function() {    GAME.physics.startSystem(Phaser.Physics.ARCADE);    mapa = GAME.add.tilemap('mapa');        mapa.addTilesetImage('meuTileset', 'tilesetImg');    mapa.setCollisionBetween(970, 1026); //tryied even 0 to 5000        this.layer = mapa.createLayer('cenario');    this.layer.resizeWorld();        this.layer2 = mapa.createLayer('detalhes');    this.layer2.resizeWorld();    PLAYER = GAME.add.sprite(GAME.world.centerX, GAME.world.centerY, 'player1');    GAME.physics.arcade.enable(PLAYER);    CURSORS = GAME.input.keyboard.createCursorKeys();}, //end createupdate : function() {        this.physics.arcade.collide(PLAYER, this.layer);        this.physics.arcade.collide(PLAYER, this.layer2);        if (CURSORS.left.isDown) {              PLAYER.body.velocity.x = -50;              PLAYER.body.velocity.y = 0;        } else if (CURSORS.right.isDown) {            PLAYER.body.velocity.x = 50;            PLAYER.body.velocity.y = 0;        } else if (CURSORS.up.isDown) {            PLAYER.body.velocity.x = 0;            PLAYER.body.velocity.y = -50;        } else if (CURSORS.down.isDown) {              PLAYER.body.velocity.x = 0;              PLAYER.body.velocity.y = 50;        }}, //end update

Please, where I am doing this wrong???

 

Link to comment
Share on other sites

Doc : http://phaser.io/docs/2.4.4/Phaser.TilemapLayer.html#resizeWorld

 

Doing it twice is useless : the last time you invoke it is the only one that's kept in the end (first time will be overridden). The world only has one size, so the last one you apply is the only one that's kept.

 

For the collisions though I can't see what's wrong : could you do a sandbox please? That would help a lot.

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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