Jump to content

Weird loading problem at "autoDetectRenderer"...


yagerGames
 Share

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);
Link to comment
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.

Link to comment
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!

Link to comment
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() {
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...