I have created a game with Phaser 3. I have it stored as a .js file in my working directory. I want the game to start when the start button is clicked on my .html index page. What am I doing wrong here?
The only thing I need to happen is for the game to run when the button is clicked, just as if I had included the script in the body
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <!-- Title of our Page --> <title>Video Game</title> <!-- Phaser 3 link here --> <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script> <!-- CSS For our page --> <style type="text/css"> html, body { margin: 0; width: 1000px !important; height: 750px !important; } script { width: 1000px !important; height: 750px !important; } </style> </head> <body> <script> var skateGame = require('skateboarding.js'); </script> <input type = "button" onclick = "skateGame" value = "Skateboarding" /> </body> </html>
skateGame, i.e.onclick = "skateGame()".requirewould work.