Hello everyone,
Me and two of my classmates are working on a game project. We are attempting to use the dom class to add the html overlay, but nothing we have done seems to work. Whether its a form or just a string of test, it doesn’t display. We have gone through the API documentation, the phaser examples on github and have found other posts here and on stack overflow with no luck. We’ve been spinning our wheels on this for the last week so we would be greatly appreciative of any assistance.
All three of us are using Chrome browser. I have been working locally with XAMPP. Below is my most recent attempt where I was trying a different approach by using the div tutorial located at Phaser - Examples - Div Depth
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Fractured Worlds</title>
<script src="//cdn.jsdelivr.net/npm/phaser@3.11.0/dist/phaser.js"></script>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'divId',
dom: {
createContainer: true
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('title', 'assets/Title1.png');
}
function create ()
{
this.add.image(200, 100, 'title');
var div1 = document.createElement('div');
div1.style = 'background-color: lime; width: 220px; height: 100px; font: 48px Arial; font-weight: bold';
div1.innerText = 'Phaser 3';
var div2 = document.createElement('div');
div2.style = 'background-color: yellow; width: 220px; height: 100px; font: 48px Arial; font-weight: bold';
div2.innerText = 'Phaser 3';
var element1 = this.add.dom(300, 0, div1);
var element2 = this.add.dom(400, 0, div2);
element1.setDepth(2);
}
</script>
</body>
</html>