I get the the error this.time.addEvent is not a function
when I try to create a timer like this:
var Minigame = new Phaser.Class({
Extends: Phaser.Scene,
initialize: function() {
Phaser.Scene.call(this, { ‘key’: ‘Minigame’ });
},
init: function(data) {
this.day = data.day;
this.time = data.time;
this.room = data.room;
},
preload: function() {
this.load.image(‘metalFloor’, ‘./assets/metalFloor.png’);
this.load.image(‘malletIcon’, ‘./assets/malletIcon.png’);
this.load.image(‘mugIcon’, ‘./assets/mugIcon.png’);
this.load.image(‘mapIcon’, ‘./assets/mapIcon.png’);
this.load.image(‘server’, ‘./assets/server.png’);
this.load.image(‘bug1’, ‘./assets/bug1.png’);
},
create: function() {
var timer = this.time.addEvent({delay: 500, callback: this.spawnBug, repeat: 4});
this.add.image(400, 300, ‘metalFloor’);
this.add.image(400, 300, ‘server’);
this.add.image(600,100, ‘mugIcon’);
this.mallet = this.add.sprite(700, 300, 'malletIcon').setInteractive();
this.mallet.on('pointerover', function(){this.mallet.setTint(0xff8f00);}, this)
this.mallet.on('pointerout', function(){this.mallet.setTint(0xffffff);}, this)
this.mallet.on('pointerdown', function(){
this.mallet.visible = false;
}, this);
Can anyone tell me what I’m doing wrong here? Couldn’t find much online about this particular issue