valueerror Posted August 8, 2014 Share Posted August 8, 2014 while i can do the following for constraints:var allConstraints = game.physics.p2.getConstraints(); if (allConstraints.length > 0){ for (i=0; i<=allConstraints.length; i++){ game.physics.p2.removeConstraint(allConstraints[i]);} }it seems that springs work different although the documentation says it works exactly the same way: var allSprings = game.physics.p2.getSprings(); if (allSprings.length > 0){ game.physics.p2.removeSpring(allSprings); }removeSpring does not take A spring .. it takes a spring array... so how would i remove a single spring then? Link to comment Share on other sites More sharing options...
Sebi Posted August 8, 2014 Share Posted August 8, 2014 According to the phaser source:World.prototype.removeSpring = function(s){ var idx = this.springs.indexOf(s); if(idx===-1){ Utils.splice(this.springs,idx,1); }}; /** * Removes a Spring from the world. * * @method Phaser.Physics.P2#removeSpring * @param {Phaser.Physics.P2.Spring} spring - The Spring to remove from the World. * @return {Phaser.Physics.P2.Spring} The Spring that was removed. */ removeSpring: function (spring) { this.world.removeSpring(spring); this.onSpringRemoved.dispatch(spring); return spring; }Looks like a bug. It should be "if(idx!==-1){". Other than this bug, it behaves the same as contraints. lol. Link to comment Share on other sites More sharing options...
valueerror Posted September 2, 2014 Author Share Posted September 2, 2014 https://github.com/photonstorm/phaser/issues/1134 this bug is now fixed! thx rich ! Link to comment Share on other sites More sharing options...
Recommended Posts