yagerGames Posted May 2, 2017 Share Posted May 2, 2017 I went to fully clear my browser history in Chrome and then my game wouldn't Init successfully. It started throwing an error here. The undefined error traced back to Pixi.js line 16. It also wouldn't Init in Firefox. I restarted my PC, and, it still wouldn't init... Then I loaded one of the samples successfully, now everything is working again without any code changes. Wtf? Gotta love HTML5... Anyone ever had anything like that happen? /** Create a Pixi stage and Renderer **/ var stage = new Container(), Renderer = autoDetectRenderer(windowWidth,windowHeight); document.body.appendChild(Renderer.view); Quote Link to comment Share on other sites More sharing options...
Zenext Posted May 2, 2017 Share Posted May 2, 2017 I suppose maybe this could help: window.onload = function() { document.body.appendChild(Renderer.view); } It probably can't find a document object as it hasn't been ready yet, when you are trying to append to it. Quote Link to comment Share on other sites More sharing options...
yagerGames Posted May 2, 2017 Author Share Posted May 2, 2017 6 minutes ago, Zenext said: I suppose maybe this could help: window.onload = function() { document.body.appendChild(Renderer.view); } It probably can't find a document object as it hasn't been ready yet, when you are trying to append to it. I was building off the learningPixi treasureHunter example as my base code. It just straight ran the code as soon as loaded. That will probably keep that from happening again. Thanks! Quote Link to comment Share on other sites More sharing options...
yagerGames Posted May 2, 2017 Author Share Posted May 2, 2017 Just to verify, I noticed my code for running my game loop is different from the current PixiJS example. Is this the current best practice for running the game loop? Also, is there any way to set target FPS lower to like 30FPS like with Flash? http://pixijs.github.io/examples/#/basics/basic.js My code: function initGame() { /** Start game loop **/ mainLoop(); } function mainLoop() { //Loop this function 60 times per second requestAnimationFrame(mainLoop); //Run game loop gameLoop(); //Render the stage Renderer.render(Stage); } function gameLoop() { Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.