Hi,
I am trying to get a text object to blink by using a timer and setting it to not be visible in my scene class. The problem is that I don’t seem to be able to reference the text object.
this.presstart = this.add.text(260, 480, 'Press enter to start', { fontFamily: 'Arial', fontSize: 20, color: '#ffffff' });
this.blinkOff = true;
this.timer = this.time.addEvent({
delay: 500,
callback: this.blinkText,
loop: true
});
console.log(this);
The above is in my create function and then in my update function I have the following:
blinkText: function() {
console.log(this.presstart);
if(this.blinkOff) {
this.presstart.visible = false;
this.blinkOff = false;
} else {
this.presstart.visible = true;
this.blinkOff = true;
}
}
In the console, I just get a message, "cannot set visible of undefined. I am having difficulty understanding how the scoping works, but I understand that a lot of this is due to my inexperience with Javascript. Other variables I have defined this way have worked when referenced in other methods. Can anyone help?