darcys22 Posted September 1, 2014 Share Posted September 1, 2014 I am trying to remove the physics effect on items in a group (shifts) when they are dragged. I am pretty much following the Arcade Physics: Gravity and Drag example. I have the following code:GameState.prototype.box = function(x, y, size) { ... blah ... var box = this.game.add.sprite(x,y,bmd); ... more blah ... box.events.onDragStart.add(this.startDrag, this); box.events.onDragStop.add(this.stopDrag(box), this); this.shifts.add(box);}GameState.prototype.startDrag = function() { //sprite.body.moves = false;}GameState.prototype.stopDrag = function(sprite) { sprite.body.moves = true;}startDrag doesn't give any errors (without the param) but I can't do anything with it. The problem I am having is when trying to pass a parameter (like with stopDrag) I get this error:[17:08:21.446] Error: listener is a required param of add() and should be a Function. @ http://localhost:8000/js/phaser.min.js:7Not really sure if I am missing something or if there is a better way of doing it. I am pretty new to both js and Phaser. Link to comment Share on other sites More sharing options...
rich Posted September 1, 2014 Share Posted September 1, 2014 onDragStart and onDragStop send 2 parameters automatically: sprite and pointer. So just change your code to:GameState.prototype.startDrag = function(sprite, pointer) { sprite.body.moves = false;} darcys22 1 Link to comment Share on other sites More sharing options...
darcys22 Posted September 1, 2014 Author Share Posted September 1, 2014 Ah sweet thanks. Is that somewhere in the Docs or Source? I am having a similar problem with input.onDown.add() Link to comment Share on other sites More sharing options...
rich Posted September 1, 2014 Share Posted September 1, 2014 In the source obviously, but also the Examples. Nearly all events in Phaser are sent something - you can quickly work out what by just sticking: console.log(arguments); in your function to see. Link to comment Share on other sites More sharing options...
Recommended Posts