suganya Posted December 6, 2017 Share Posted December 6, 2017 update: function() { // game.physics.arcade.collide(turnip, background); if (this.time.now+500 > planttime) { sprite=game.add.sprite(game.rnd.integerInRange(1000, 1000)+100, game.rnd.integerInRange(500, 600), 'atlas', "BG" + game.rnd.integerInRange(0, 2)); game.physics.enable(sprite, Phaser.Physics.ARCADE); sprite.body.immovable = true; sprite.body.velocity.x=-500; planttime=planttime+3500; game.physics.arcade.collide(turnip, background,self.collisionHandler,null,this); } }, collisionHandler:function () { console.log("collide"); }, Link to comment Share on other sites More sharing options...
DanielKlava Posted December 6, 2017 Share Posted December 6, 2017 Hello there! I think that you should use "this.collisionHandler" instead of "self.collisionHandler". Generally, the object "self" will point to window.self, and "this" will point to the context the function is in. Since you want to use the function "collisionHandler" in the context of the Game (or State) object, you should reference the function with "this". Hope it works suganya 1 Link to comment Share on other sites More sharing options...
suganya Posted December 8, 2017 Author Share Posted December 8, 2017 its works thanks Link to comment Share on other sites More sharing options...
Recommended Posts