Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: set element.visible to false #21

Open
cinead opened this issue Dec 18, 2015 · 1 comment
Open

Feature Request: set element.visible to false #21

cinead opened this issue Dec 18, 2015 · 1 comment

Comments

@cinead
Copy link

cinead commented Dec 18, 2015

Can you add CanvasInput.hide and CanvasInput.unhide methods that set the rendered objects to visible or invisible (and simultaneously disable input)?

This would make the CanvasInput library act more like the other text objects already being used in the Phaser library.

I use the CanvasInput method as a text input box along with other Phaser.game text objects. I have a .hide() method that sets a field for text objects and makes them invisible:
visible=false.
However, I can't apply this same method to the text input box inheriting from CanvasInput.

@cinead
Copy link
Author

cinead commented Dec 18, 2015

this.hide = function() {
    //hide all window elements and turn off their Inputs
    for (var i = 0; i < this.elements.length; i++) {    
        this.elements[i].visible = false;
    }
    for (var i = 0; i < this.inputs.length; i++) {  
        this.inputs[i].InputEnabled = false;
    }
    return this;
}
this.unhide = function(activeWindow) {
    try {activeWindow.hide();}
    catch(e) {console.log(e);};
    //unhide this window's elements:
    for (var i = 0; i < this.elements.length; i++) {    
        this.elements[i].visible = true;
    }
    for (var i = 0; i < this.inputs.length; i++) {  
        this.inputs[i].InputEnabled = true;
    }
    //return the unhidden window:
    return this;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant