Reputation: 8216
I have an image and some text that I want to show/hide:
overlay = this.game.add.image( 0, 0, this.custom_texture.generateTexture() );
overlay_text = this.game.add.text( 0, 0, 'TESTING 123', style );
I tried the destroy()
function, but I wasn't able to bring them back, plus I don't think it's necessary to destroy them if I simply want to hide & show them.
Upvotes: 14
Views: 18083
Reputation: 286
In one Liner, we can toggle hide/show.
overlay.visible= !overlay.visible;
overlay_text.visible = !overlay_text.visible;
Upvotes: 3
Reputation: 8216
It's more intuitive than I thought it would be.
To hide:
overlay.visible = false;
overlay_text.visible = false;
To Show:
overlay.visible = true;
overlay_text.visible = true;
Upvotes: 31