Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crafty wont display in Electron #1204

Open
0xf0xx0 opened this issue Dec 17, 2018 · 6 comments
Open

Crafty wont display in Electron #1204

0xf0xx0 opened this issue Dec 17, 2018 · 6 comments

Comments

@0xf0xx0
Copy link

0xf0xx0 commented Dec 17, 2018

Hello again 👋
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>
@kevinsimper
Copy link
Contributor

Hi @gingkathfox, what error do you get? :)

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 18, 2018

@kevinsimper TypeError, Crafty.scene is not a function

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 18, 2018

Uncaught TypeError: Crafty.scene is not a function
at Level1.js:4

@kevinsimper
Copy link
Contributor

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

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 19, 2018

@kevinsimper Does Codepen use Electron? My game runs fine using Beefy.
EDIT: youll have to uncomment the document.getElementById('game'), its on line 7.

@0xf0xx0
Copy link
Author

0xf0xx0 commented Dec 19, 2018

Heres the zip of the files used by Electron:
Archive.zip
Do i need to include the package.json?

@0xf0xx0 0xf0xx0 changed the title Crafty wont display in html page Crafty wont display in Electron Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants