Jump to content

Params to a listener


darcys22
 Share

Recommended Posts

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:7

Not 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

 Share

  • Recently Browsing   0 members

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