pikminman Posted January 1, 2018 Share Posted January 1, 2018 Happy new year! I'm trying to wrap my Phaser game into a Cordova app so I can publish it on the Play Store. It's not working though and I'm tearing what's left of my hair out Here is my HTML code: <html> <head> <script type='text/javascript'> alert('hi'); </script> <style> body { margin: 0; } </style> </head> <body> <span id='root'></span> <script type="text/javascript" src="cordova.js"></script> <!-- I also used the CDN and with/without async defer --> <script async defer src="./js/phaser.js"></script> <script async defer src='./js/index.js'></script> </body> </html> And here is the relevant part of the js: window.onerror = function(msg, url, linenumber) { alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber); return true; } document.addEventListener("deviceready", onDeviceReady, false); // I tried with and without onDeviceReady() function onDeviceReady() { // All game code here } But, when I run it with `cordova build`, and put the APK on my phone, it gives me a reference error. Something along the lines of 'Phaser is not definied'. I've tried looking for ways to include a library under cordova but no luck. Am I missing something obvious? P.S. It works perfectly in the browser and the alerts do come up in the Cordova build Link to comment Share on other sites More sharing options...
bruno_ Posted January 2, 2018 Share Posted January 2, 2018 Don't use async defer. I know you already tried, but its simpler to start if you don't use it. Try not to use a dot in the path, use something like src="phaser.js", with the script in the same folder as the html. This way you are certain that the path is correct. Link to comment Share on other sites More sharing options...
Recommended Posts