I'm trying to have some text appear when the mouse hovers over an item in the invetory.
Here is the code I have for a key appearing in the inventory, disappearing when its used in its quest, and what should make text appear when the player hovers over it:
if(this.pack[0] != null){
if (this.pack[0] == "key"){
this.key = this.physics.add.sprite(180, 150, 'key').setInteractive();
this.key.body.immovable = true;
this.key.body.allowGravity = false;
this.key.setScale(4);
this.key.texture.setFilter(Phaser.Textures.FilterMode.NEAREST);
}
}
this.key.on('pointerdown', function (pointer) {
this.line1.setText('Peef: Its the key to the bedroom door.');
this.line2.setText('Bandit hid it under the bad for some reason. Probably just playing.');
}, this);
if(tutorial == "complete"){
this.key.destroy();
}
Unfortunatly, I can't seem to get the mouse to work at all. I've tried changing some of the words around, from pointerdown to pointerover, or from pointer to gameobject, to moving everything under one if statement or from the update to the create method, but none of them got the result I want. Does anyone know what the correct code for what I want is?
If it helps, I'm using Phaser 3 in VSCode employing arcade physics.