Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Is there a collision exempt function


xronn
 Share

Recommended Posts

Hi, so I was wondering the best way to go about making my collision changes, I have 899 tiles and randomly dotted throughout the tiles are some I don't want the player to collide with is it possible to set a collision range E.g tiles "0, 899" then add an exempt collision e.g "exempt.collision(0,334,33,44,446,676);" Those tiles would not have collision on them, or do I just have to set loads of ranges.

 

thanks!

Link to comment
Share on other sites

/**

* Sets collision on all tiles in the given layer, except for the IDs of those in the given array.

* The `collides` parameter controls if collision will be enabled (true) or disabled (false).

*

* @method Phaser.Tileset#setCollisionByExclusion

* @param {array} indexes - An array of the tile IDs to not be counted for collision.

* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.

* @param {number|string|Phaser.TilemapLayer} [layer] - The layer to operate on. If not given will default to this.currentLayer.

*/

setCollisionByExclusion: function (indexes, collides, layer)

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I tried changing it up to get it working but still having trouble

Uncaught TypeError: Object #<Object> has no method 'setCollisionByExclusion' 

This is my game code:

 

        //Loads the map        map = this.add.tilemap('level1');        tileset = this.add.tileset('tiles');        //Collision range        // tileset.setCollisionRange(0, 57, true, true, true, true);        // tileset.setCollisionRange(60, 62, true, true, true, true);        // tileset.setCollisionRange(90, 92, true, true, true, true);        // tileset.setCollisionRange(632,656, true, true, true, true);        // tileset.setCollisionRange( )        // tileset.setCollisionRange(97, 799, true, true, true, true);        // tileset.setCollisionRange(804, 899, true, true, true, true);        map.setCollisionByExclusion([93,94,95,96], true);

Thanks, I didn't include the last parameter as it auto assigns which is fine

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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