# Just once (collision)

**URL:** <https://phaser.discourse.group/t/just-once-collision/6693>\
**Category:** Phaser 3\
**Created:** [June 15, 2020, 8:19pm UTC](https://phaser.discourse.group/t/just-once-collision/6693 "2020-06-15T20:19:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![buqer\_ok](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/buqer_ok/32/3444_2.png) [@buqer\_ok](https://phaser.discourse.group/u/buqer_ok)\
**Post date:** [June 15, 2020, 8:19pm UTC](https://phaser.discourse.group/t/just-once-collision/6693/1 "2020-06-15T20:19:13Z")

</div>

How to make the sprite’s player collide with another sprite and add 5 points to score, but only do it once.

---

<div class="post-metadata">

**Author:** ![ghclark2](https://avatars.discourse-cdn.com/v4/letter/g/8491ac/32.png) [@ghclark2](https://phaser.discourse.group/u/ghclark2)\
**Post date:** [June 16, 2020, 2:16am UTC](https://phaser.discourse.group/t/just-once-collision/6693/2 "2020-06-16T02:16:18Z")

</div>

Collisions will keep firing as long as the two things are touching. Depending on your situation, you need to do something like kill one of the sprites, have the two sprites bounce apart or set a timer as a process callback to only allow a second collision after a certain amount of time. More details needed and your current code…

---

<div class="post-metadata">

**Author:** ![buqer\_ok](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/buqer_ok/32/3444_2.png) [@buqer\_ok](https://phaser.discourse.group/u/buqer_ok)\
**Post date:** [June 16, 2020, 5:37pm UTC](https://phaser.discourse.group/t/just-once-collision/6693/3 "2020-06-16T17:37:24Z")

</div>

I want to make this:

\_Add 5 points to player  
\_Subtract 5 points to enemy  
\_Destroy object “base”  
\_Create sprite (50, 100, ‘sword’)  
\_Wait 1 second **// I don’t understand this part**  
\_And then set Player.y = 600

Could someone help me with the time event?

---

<div class="post-metadata">

**Author:** ![ghclark2](https://avatars.discourse-cdn.com/v4/letter/g/8491ac/32.png) [@ghclark2](https://phaser.discourse.group/u/ghclark2)\
**Post date:** [June 16, 2020, 5:50pm UTC](https://phaser.discourse.group/t/just-once-collision/6693/4 "2020-06-16T17:50:55Z")

</div>

Let timer = scene.time.delayedCall(delay, callback, args, scope); // delay in ms

So for example  
let timer = scene.time.delayedCall(1000, () =\> {this.player.y = 600}, [], this) ; // delay in ms

[https://photonstorm.github.io/phaser3-docs/Phaser.Time.Clock.html](https://photonstorm.github.io/phaser3-docs/Phaser.Time.Clock.html)

---

<div class="post-metadata">

**Author:** ![buqer\_ok](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/buqer_ok/32/3444_2.png) [@buqer\_ok](https://phaser.discourse.group/u/buqer_ok)\
**Post date:** [June 16, 2020, 8:58pm UTC](https://phaser.discourse.group/t/just-once-collision/6693/5 "2020-06-16T20:58:33Z")

</div>

I solved!

this.time.addEvent({callback: () =\> {jugador.y = 600}, delay: 1000, callbackScope: this, loop: true})

---

<div class="post-metadata">

**Author:** ![ghclark2](https://avatars.discourse-cdn.com/v4/letter/g/8491ac/32.png) [@ghclark2](https://phaser.discourse.group/u/ghclark2)\
**Post date:** [June 16, 2020, 10:14pm UTC](https://phaser.discourse.group/t/just-once-collision/6693/6 "2020-06-16T22:14:57Z")

</div>

Unless you want jugador’s y position to be set to 600 every second indefinitely, then I suggest changing loop to false 😊
