timeEvent in overlap not working

Hello i am really new in phaser maybe one week so please be patient :smiley: thank you :slight_smile:

   this.physics.add.overlap(player, enemy, stret, null, this);
           	function stret(){

                 this.time.addEvent({
                          delay: 500,
                          callback: ()=>{
                                myhp-=1; 
                           },
                           loop: true
                           })
       	}

Everytime my “player” and my “enemy” overlap i need to lower “myhp” every 500ms. But this code will continuously lower my hp no every 500ms. I doesnt look like by i tried everything. Four hours or maybe more of trying to resolve this simple code…Please help me , thank you very much.

This is one of first thing to learn in phaser i belive you know it guys. :confused:

Still hopeless, this is blocking all my progress please guys

Are the two sprites overlapping continuously?

It is dynamic player who can move left right and also dynamic enemy .They can overlap for second or forever depend on player movement . It works like after delay it starts but loop is not working and then it count down “myhp” continuously(not in loop) until i move away (=>not overlapping)

When I put this timeEvent to update with some boolean which checking if they are overlapping it works but I didn’t know how to say if they are NOT overlapping. -> but I thought there would be some easy Phaser command not 10 boolean and 15 if else