xronn Posted February 4, 2014 Share Posted February 4, 2014 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 More sharing options...
rich Posted February 4, 2014 Share Posted February 4, 2014 /** * 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) jerome 1 Link to comment Share on other sites More sharing options...
xronn Posted February 4, 2014 Author Share Posted February 4, 2014 Thanks Rich! big help Link to comment Share on other sites More sharing options...
xronn Posted February 17, 2014 Author Share Posted February 17, 2014 Bump, I just got round to adding this is it something like this? setCollisionByExclusion: function ([93,94,95,96], true);Also do I need to put it in the create function or is it it's own. Link to comment Share on other sites More sharing options...
rich Posted February 17, 2014 Share Posted February 17, 2014 It's done on the tilemap directly: map.setCollisionByExclusion() and yes do it in the create function. Link to comment Share on other sites More sharing options...
xronn Posted February 17, 2014 Author Share Posted February 17, 2014 Hi, I tried changing it up to get it working but still having troubleUncaught 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 More sharing options...
rich Posted February 18, 2014 Share Posted February 18, 2014 Hmm you definitely using Phaser 1.1.4? Link to comment Share on other sites More sharing options...
xronn Posted February 18, 2014 Author Share Posted February 18, 2014 Ahh, I was using1.1.3 - Built at: Fri Nov 29 2013 18:20:59Is this feature only available in 1.1.4? Thanks! Link to comment Share on other sites More sharing options...
rich Posted February 18, 2014 Share Posted February 18, 2014 Yes, but there are other issues with 1.1.4 (physics related mostly), so if you're already working on a game I would stay put for now probably. Depends on the game type really. Link to comment Share on other sites More sharing options...
xronn Posted February 18, 2014 Author Share Posted February 18, 2014 Hmm, Okay I will stick with 1.1.3, my game is top down and I don't think it will need any physics I'll stick to what I know and just add ranges or re-arrange my tiles so that all the collide able ones are at the start not dotted throughout. Thanks Rich! Link to comment Share on other sites More sharing options...
Recommended Posts