# Call to timer methods not working

**URL:** https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095
**Category:** Phaser 3
**Created:** [August 4, 2020, 8:07pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095 "2020-08-04T20:07:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Chair](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chair](https://phaser.discourse.group/u/Chair)
#### Post date: [August 4, 2020, 8:07pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/1 "2020-08-04T20:07:52Z")

</div>

Hello, in my game, I have a timer that is constantly looping that I want to turn off for a bit and then turn on again later. I declare the timer initially like this:

```
var enemyTimer = this.time.addEvent({
	delay: 1500,
	callback: this.changeEnemyDirection,
	callbackScope: this,
	loop: true
});

```

which works fine. However, I have not been successfully able to remove and recreate it. I’ve been trying to use the Timer API’s remove() method like this:

```
this.enemyTimer = this.time.remove({
		delay: 1500,
		callback: this.changeEnemyDirection,
		callbackScope: this,
		loop: true
});

```

Is there something wrong with my syntax? I couldn’t find anything online yet that shows it otherwise.

---

<div class="post-metadata">

### Author: ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)
#### Post date: [August 4, 2020, 8:16pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/2 "2020-08-04T20:16:16Z")

</div>

Try call just this.enemyTimer.remove();

---

<div class="post-metadata">

### Author: ![Chair](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chair](https://phaser.discourse.group/u/Chair)
#### Post date: [August 4, 2020, 9:44pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/3 "2020-08-04T21:44:11Z")

</div>

The same issue comes up where it says “Cannot read property ‘remove’ of undefined” when I tried that.

---

<div class="post-metadata">

### Author: ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)
#### Post date: [August 4, 2020, 9:50pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/4 "2020-08-04T21:50:08Z")

</div>

You declared:

var enemyTimer.

But call it with this.enemyTimer.

Try to declare with this.enemyTimer and it will work

---

<div class="post-metadata">

### Author: ![Chair](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chair](https://phaser.discourse.group/u/Chair)
#### Post date: [August 5, 2020, 5:05am UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/5 "2020-08-05T05:05:15Z")

</div>

This was what I tried when I got the “Cannot read property of ‘remove’ of undefined” :(( ![remove()](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/4/49cd6e107514ee9a75e70ecaeaad7e6ab5711d04.png)

---

<div class="post-metadata">

### Author: ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)
#### Post date: [August 5, 2020, 10:19am UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/6 "2020-08-05T10:19:02Z")

</div>

In your first screen of this post, replace var by this  
var enemyTimer is a variable  
this.enemyTimer is an attribut  
There are not the same, i suggest you to read tutorials about class in js, you’ll learn things useful to develop with phaser3

---

<div class="post-metadata">

### Author: ![Thyebe](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thyebe/32/3799_2.png) [@Thyebe](https://phaser.discourse.group/u/Thyebe)
#### Post date: [August 5, 2020, 12:24pm UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/7 "2020-08-05T12:24:07Z")

</div>

Like @BlunT76 said, change:

> [@Chair](#):
>
> ```javascript
> var enemyTimer = this.time.addEvent({
> delay: 1500,
> callback: this.changeEnemyDirection,
> callbackScope: this,
> loop: true
> });
> 
> ```

To:

```javascript
this.enemyTimer = this.time.addEvent({
	delay: 1500,
	callback: this.changeEnemyDirection,
	callbackScope: this,
	loop: true
});
```

---

<div class="post-metadata">

### Author: ![Chair](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chair](https://phaser.discourse.group/u/Chair)
#### Post date: [August 7, 2020, 5:09am UTC](https://phaser.discourse.group/t/call-to-timer-methods-not-working/7095/8 "2020-08-07T05:09:19Z")

</div>

Thanks guys!
