Crafty
Crafty copied to clipboard
Crafty wont display in Electron
Hello again :wave: I have a issue with running crafty without Beefy+Browserify. I need my game to run in Electron, and the only issue i have right now is that i cant figure out how to run the game in a html page. Heres my code+markup:
// Relevant code
Crafty.scene('main', function() {
Crafty.init(500,500, document.getElementById('game'));
// rest of 'main' here...
}
window.onload = function() {
Crafty.scene('main')
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Overtime-game</title>
</head>
<body>
<div id="game"></div>
<script type='text/javascript' src='./node_modules/craftyjs/dist/crafty.js'></script>
<script src='./Level1.js'></script>
</body>
</html>
Hi @GingkathFox, what error do you get? :)
@kevinsimper TypeError, Crafty.scene is not a function
Uncaught TypeError: Crafty.scene is not a function
at Level1.js:4
Looks like either the code is not loaded, as the code for scene is correct. Can you create a codepen that shows the error, I can't sadly help you without having all the code available.
You can see the actual code Crafty.scene is https://github.com/craftyjs/Crafty/blob/develop/src/core/scenes.js
@kevinsimper Does Codepen use Electron? My game runs fine using Beefy.
EDIT: youll have to uncomment the document.getElementById('game')
, its on line 7.
Heres the zip of the files used by Electron: Archive.zip Do i need to include the package.json?