xkorikx Posted May 4, 2014 Share Posted May 4, 2014 Hi Phaser users.I have an problem with overlap function.Overlap created in update, so it run every frame. But problem is that overlap happens over ten times while sprite moving through it.How can I code that if sprite overlap with other object, they will never overlap again?I think about killing object that overplap with sprite, and then copy his attributes to other object that wont overlap with sprite. Maybe you will suggest better solution.create: function() { // Add player to scene this.poring = this.add.sprite(60, 128, 'poring'); this.physics.arcade.enable(this.poring); this.poring.body.bounce.y = 0; this.poring.body.gravity.y = 800; this.poring.body.collideWorldBounds = true; this.poring.animations.add('run', [0,1,2,3,4], 10, true); this.poring.animations.play('run'); // Bush this.bushes = this.add.group(); this.bushes.enableBody = true; this.bushes.createMultiple(10, 'prontera_bush');},update: function() { // Overlap poring and bush this.physics.arcade.overlap(this.poring, this.bushes, this.lose, null, this);},// This will be triggered a lot of timeslose: function(poring, bush) { this.state.start('GameOver');}, Link to comment Share on other sites More sharing options...
codevinsky Posted May 5, 2014 Share Posted May 5, 2014 You can set: bush.exists = false; in your overlap handler. This will cause the engine to ignore that bush until bush.exists is set back to true. Link to comment Share on other sites More sharing options...
xkorikx Posted May 5, 2014 Author Share Posted May 5, 2014 You can set: bush.exists = false; in your overlap handler. This will cause the engine to ignore that bush until bush.exists is set back to true. Oh. I don't know about that, thanks. Link to comment Share on other sites More sharing options...
Ningenbitto Posted November 10, 2014 Share Posted November 10, 2014 I tried to set the object "exists = false", but having animation when one hit, the animation is not running. : / Anyone knows it can be? Link to comment Share on other sites More sharing options...
Recommended Posts