Jump to content

Game needs to be refreshed several times to make it work


Juls
 Share

Recommended Posts

Hi everyone.
I'm creating a game and I was testing it into different browsers.
I always use Chrome for my tests and everything is fine there. I tried on Edge and it works perfect as in Chrome.
Then I opened it in Firefox and there's a problem.
It opens the preloader, the mainMenu page in which there is the name of the game and two buttons, but as I try to click on the "play" button, which brings me to the actual game, I have no answers.
When I open the page I get these messages in firefox console log:

Quote

Error: WebGL: Failed to create WebGL context: WebGL is currently disabled.phaser.min.js:17:31459
Error: WebGL: Failed to create WebGL context: WebGL is currently disabled.phaser.min.js:17:31482
“mozHidden” and “mozVisibilityState” are deprecated. Use instead the versions without prefix, “hidden” and “visibilityState”.phaser.min.js:11:7856
"Phaser v2.6.1 | Pixi.js v2.2.9 | Canvas | WebAudio | http://phaser.io"phaser.min.js:12:1437
TypeError: this.events[this._i].callback is null [Ulteriori informazioni]phaser.min.js:19:9535
       c.Timer.prototype.update()  phaser.min.js:19
       c.Time.prototype.update()   phaser.min.js:19
       c.Game.prototype.update()  phaser.min.js:12
       c.RequestAnimationFrame.prototype.updateRAF()   phaser.min.js:18
       c.RequestAnimationFrame.prototype.start/this._onLoop()    phaser.min.js:18


I think the WebGL error is a Phaser one, because I use CANVAS in my game: (in index.html) 

 var game = new Phaser.Game(800, 600, Phaser.CANVAS,'');

And I guess that the "mozHidden" etc line is just a warning.

So that TypeError must be the issue. What is the problem with those lines? What am I doing wrong with the instantiation of my game?
Is it a problem that I use prototypes for my game like: (in Level1.js)

Game.Level1 = function(game)
{  };

Game.Level1.prototype = {
    preload:function(game){
        //...
    },
    create:function(game){
        //...
    }
};


Oh, and I tried opening the game in the Firefox safe-mode, without the additional plug-ins, and it works like it should be.
Any help would be really appreciated!
Thank you very much.

EDIT
I tried deleting the cache on Chrome and Edge and it doesn't work immediately even there, giving me some phaser errors like the ones before. But no error about my code.
And if I refresh the page several times, like 4 or 5 or more, it begins working again like it should.
What could this problem be due to?

Link to comment
Share on other sites

4 hours ago, tips4design said:

You think it's an WebGL error? It is, it's mentioned in that error text: 


Error: WebGL: Failed to create WebGL context: WebGL is currently disabled.

Always look at the first error you get, ignore the rest. It says that WebGL is disabled. See this on how to enable WebGL in your browser: http://superuser.com/a/836833/55913

I guess it's not a WebGL error because using CANVAS I should never use WebGL so I don't think that's the problem..

23 minutes ago, rgk said:

I've had this issue before, wait a few upgrades and Firefox might start working again. I've had Firefox on windows work but when I used Firefox on Linux it didn't.

Thank you for your answers, I edited my post as I noticed that the issue is common on any of my browsers:
if I delete the cache even on Chrome or Edge I get the same problem.
And only if I refresh the same page about 4-5-6 times I get things to work (which doesn't happen on Mozilla - it just happens there if I use the safe-mode version).
Do you know why could this be happening?

Link to comment
Share on other sites

The "Failed to create WebGL context" message is normal (when WebGL is disabled). It comes from Phaser testing for device capabilities.

5 hours ago, Juls said:

TypeError: this.events[this._i].callback is null

Maybe you have a timer event that should be deleted before changing state.

Link to comment
Share on other sites

1 hour ago, samme said:

The "Failed to create WebGL context" message is normal (when WebGL is disabled). It comes from Phaser testing for device capabilities.

Maybe you have a timer event that should be deleted before changing state.

I don't have any timer events..
I may have found the reason for this problem: I was using Google Web Fonts.
TI found out that as I deleted the cache from all of my browsers, and then deleted all the code about/using google fonts, replacing the fonts with a standard one like Arial, it just works. On all browsers, without the need to refresh anything.
I don't know why this is happening. 
For Google webFonts I followed the phaser tutorial on how to use Google webfonts and put the first part of the code in my index.html: 

//  The Google WebFont Loader will look for this object, so create it before loading the script.
WebFontConfig = {

    //  'active' means all requested fonts have finished loading
    //  We set a 1 second delay before calling 'createText'.
    //  For some reason if we don't the browser cannot render the text the first time it's created.
    active: function() { game.time.events.add(Phaser.Timer.SECOND, createText, this); },

    //  The Google Fonts we want to load (specify as many as you like in the array)
    google: {
      families: ['Revalia']
    }

The loader script in my Boot.js preloader:

Game.Boot.prototype={
    preload:function(){
        //  Load the Google WebFont Loader script
        this.load.script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js');
        //...

And finally the font in a text object in my MainMenu.js:

 var txt = game.add.text(button1.x,button1.y,string, {font:"40.5px Revalia", fill: "#fff", align:"center"});

And I always had to refresh the page at least one time in order to see the font working (only when I had just cleaned the cache). 

Should I try some other solutions other then Google WebFonts for my fonts in the game?
Or maybe am I doing something wrong while instantiating them, or is this a common issue?
 

Link to comment
Share on other sites

1 minute ago, samme said:

Do you have a `createText` function?

Sorry I copy pasted that part wrong, I do not have that function, I put 

active: function() { game.time.events.add(Phaser.Timer.SECOND, null, this);

as I do not have any text to display in index.html, so no function to call in there

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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