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.
In case you want to show one sprite on key press "a" and hide the other sprite and do the opposite in case of key press "b" then this is pretty simple. Here below you see the script for the sprite that must be shown on "b" keypress.
The Hide Block control allows you to completely hide any block in WordPress from public view. It was one of the first controls included in Block Visibility, all the way back in version 1.0.
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;
In one Liner, we can toggle hide/show.
overlay.visible= !overlay.visible;
overlay_text.visible = !overlay_text.visible;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With