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
ExperiBass opened this issue Dec 17, 2018 · 6 comments
Open

Crafty wont display in Electron #1204

ExperiBass opened this issue Dec 17, 2018 · 6 comments

Comments

@ExperiBass
Copy link

ExperiBass 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? :)

@ExperiBass
Copy link
Author

@kevinsimper TypeError, Crafty.scene is not a function

@ExperiBass
Copy link
Author

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

@ExperiBass
Copy link
Author

ExperiBass 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.

@ExperiBass
Copy link
Author

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

@ExperiBass ExperiBass 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