Taggrin Posted October 2, 2015 Share Posted October 2, 2015 Hi everyone, I am looking for a way to check the end of an overlap. I've been looking for quite some time without success, so I hope any of you can help me. Basic summary of the game: space shooter where you can go to planets to buy / restock items. There is an oxygen bar slowly ticking down, but I want it to stop ticking down while being docked at a planet. What I have so far is (important parts cut out)://In createship.docked = false;//In updatethis.physics.arcade.overlap(ship,planets,this.docking,null,this);//Reduce oxygen over timethis.oxygenTick();//Collision handler docking: function (ship,planets) { ship.docked = true; }, //Oxygen ticksoxygenTick: function () { //One tick of oxygen every 2 seconds if (ship.docked == false){ if (this.time.now > oxygenTime){ ship.oxygen -= 1; oxygenBar.scale.x = (ship.oxygen / ship.oxygenmax); oxygenTime = this.time.now + 2000; } }},So pretty much what happens now is that as soon as I "dock" at a planet, the oxygen stops ticking down. However, this will stay permanent, even after leaving the planet. I want to check that the ship is NOT overlapping any planet (group) anymore to set ship.docked back to false. Anyone knows a way to do this? Thanks in advance . Link to comment Share on other sites More sharing options...
bruno_ Posted October 3, 2015 Share Posted October 3, 2015 I haven't tested, but when overlapping ends won't be a collide again? Link to comment Share on other sites More sharing options...
AzraelTycka Posted October 3, 2015 Share Posted October 3, 2015 Hello, how about just putting ship.docked = false; into update loop as well?// updateship.docked = false;collisionticks Link to comment Share on other sites More sharing options...
Taggrin Posted October 3, 2015 Author Share Posted October 3, 2015 Hello, how about just putting ship.docked = false; into update loop as well?// updateship.docked = false;collisionticks That works, thank you very much! Sometimes the easy solutions are overlooked hehe. I first thought it might would give some issues as it basically is constantly flipping false/true in the update function when docked, but since the oxygen ticks are after the collision detection this indeed does the job. Link to comment Share on other sites More sharing options...
Recommended Posts