ibb671 Posted June 2, 2016 Share Posted June 2, 2016 Hello I'm new to phaser and would like to ask for help. I am trying to make a matching game. Where if its not a match the sprite would reset to its position,disable drag and after 1 second to enable drag again. I used a timer and was getting this error Uncaught TypeError: Cannot read property 'apply' of undefined. update:function(){ this.game.physics.arcade.overlap(this.playerGroup,this.imageGroup,this.checkCorrect,null,this); }, checkCorrect:function(player,sprites){ if(player.customParams==sprites.customParams){ player.inputEnabled=false; player.kill(); sprites.kill(); }else{ player.input.draggable = false; player.reset(player.OriginalX,player.OriginalY); this.game.time.events.add(1000,this.dragPlayer(player),this); } }, dragPlayer:function(player){ player.input.enableDrag() } Thanks in advance Link to comment Share on other sites More sharing options...
Str1ngS Posted June 2, 2016 Share Posted June 2, 2016 The second parameter of time.events.add requires a function, but you are actually calling the function there on runtime which cause the time.events.add to call the result of this function, which is void. You can't apply on void (which is happening behind the scenes) so you need to do something like: this.game.time.events.add(1000,function () { this.dragPlayer(player) },this); Link to comment Share on other sites More sharing options...
ibb671 Posted June 2, 2016 Author Share Posted June 2, 2016 Thank you so much. That worked. Link to comment Share on other sites More sharing options...
Recommended Posts