Files
BreakEscape/simple-phaser-test.html

103 lines
2.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Phaser Test</title>
<style>
body {
font-family: Arial, sans-serif;
background: #1a1a1a;
color: #ffffff;
margin: 0;
padding: 20px;
}
.test-container {
max-width: 800px;
margin: 0 auto;
background: #2a2a2a;
border-radius: 10px;
padding: 20px;
}
.test-container h1 {
text-align: center;
color: #00ff00;
}
#phaser-container {
width: 600px;
height: 400px;
background: #333;
border-radius: 5px;
margin: 20px auto;
border: 2px solid #444;
}
.status {
text-align: center;
margin: 20px 0;
padding: 10px;
background: #444;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="test-container">
<h1>Simple Phaser Test</h1>
<div class="status" id="status">Loading...</div>
<div id="phaser-container"></div>
</div>
<!-- Load Phaser.js -->
<script src="https://cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.min.js"></script>
<script>
document.getElementById('status').textContent = 'Phaser loaded, creating game...';
// Simple test scene
class TestScene extends Phaser.Scene {
constructor() {
super({ key: 'TestScene' });
}
create() {
document.getElementById('status').textContent = 'Phaser scene created successfully!';
// Create a simple rectangle
const graphics = this.add.graphics();
graphics.fillStyle(0x00ff00);
graphics.fillRect(100, 100, 200, 100);
// Add some text
this.add.text(200, 150, 'Phaser Works!', {
fontSize: '24px',
fill: '#ffffff'
}).setOrigin(0.5);
console.log('Test scene created successfully');
}
}
// Game config
const config = {
type: Phaser.AUTO,
parent: 'phaser-container',
width: 600,
height: 400,
backgroundColor: '#1a1a1a',
scene: TestScene
};
try {
const game = new Phaser.Game(config);
console.log('Phaser game created:', game);
} catch (error) {
console.error('Error creating Phaser game:', error);
document.getElementById('status').textContent = 'Error: ' + error.message;
}
</script>
</body>
</html>