-
Couldn't load subscription status.
- Fork 7.1k
Closed
Description
Version
- Phaser Version: Master
- Operating system: Mac OS
- Browser: Chrome/Safari
Description
If a DOMElement is added to a container and then we try to set the visibility (e.g to hide it) on the container it does not work. Setting visibility on the element directly works. However if you set visibility on the container then after that even setting visibility on the element does not work. Modified code from phaser examples to illustrate the problem below.
Example Test Code
var config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
parent: 'phaser-example',
width: 800,
height: 600
},
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
dom: {
createContainer: true
},
scene: {
preload: preload,
create: create
}
};
var element;
var cont;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('einstein', 'assets/pics/ra-einstein.png');
}
function create ()
{
var div = document.createElement('div');
div.style = 'background-color: lime; width: 220px; height: 100px; font: 48px Arial; font-weight: bold';
div.innerText = 'Phaser 3';
element = this.add.dom(400, 300, div);
cont = this.add.container(0,0);
cont.add(element);
cont.setVisible(false);
// uncommenting below will also not work unless we comment out the cont.setVisible(false)
//element.setVisible(false);
this.add.image(400, 300, 'einstein');
}
Additional Information
Metadata
Metadata
Assignees
Labels
No labels