Sign in to follow this  
yagerGames

Weird loading problem at "autoDetectRenderer"...

Recommended Posts

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);

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

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() {

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.