Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by fugufish

been scratching my head for a while, couldn't find the problem

I keep getting the error:

this.delegate is null at line 98 of system.js

it appears that the run() function in system.js failed in my firefox

line 98: this.delegate.run();

PS: on Chrome and Safari, it runs flawlessly

1 decade ago by fugufish

additional info:

the error caused the game bar to load up to around 90% and it stalls

1 decade ago by dominic

Are you using ig.main() to start your game, or did you write your own code for that? Is your Game class extended from ig.Game? Did you overwrite the .run() method?

Can you maybe provide some sample code? Otherwise it will be pretty hard to figure out what's causing this problem.

1 decade ago by fugufish

found the problem

apparently it stems from the game pause function I made

the following code does not work, because I called ig.game without checking if it's true in the first place

window.addEventListener("blur", function () {
	if (ig.system) {
		ig.game.font.draw('Game Paused',ig.system.width/2,ig.system.height/2,ig.Font.ALIGN.CENTER);

		ig.system.stopRunLoop.call(ig.system);
		soundManager.pauseAll();
	}
}, false);


a simple loop added did the trick!

 if(ig.game) 

1 decade ago by fugufish

hmm this is weird,

apparently for Firefox,

if I load the game without having focus on the main window (i.e I click on the search bar, then click on a shortcut to the game), everything runs OK

but if I first click (focus) on the main window, and then launch the game , I get the error.

definitely has something to do with the addEventListener function I used

the code I used in main.js

ig.module( 
	'game.main' 
)
.requires(
	// the standard entities
)
.defines(function(){
    MyGame = ig.Game.extend({
          // standard game codes here ( init, update, loadLevel, etc ). No run() function used

    });

window.addEventListener("blur", function () {
	if (ig.system) {
		if(ig.game){
			ig.game.font.draw('Game Paused',ig.system.width/2,ig.system.height/2,ig.Font.ALIGN.CENTER);			
		}
		ig.system.stopRunLoop.call(ig.system);
		soundManager.pauseAll();
	}
}, false);

window.addEventListener("focus", function () {
	if (ig.system) {
		ig.system.startRunLoop.call(ig.system);
		soundManager.resumeAll();
	}
}, false);


});

1 decade ago by fugufish

i tried this


ig.module( 
	'game.main' 
)
.requires(
	// the standard entities
)
.defines(function(){

    var gameStarted = false;

    MyGame = ig.Game.extend({
          // standard game codes here ( init, update, loadLevel, etc ). No run() function used
          init:function(){
              // standard codes here
              gameStarted = true;
          },

    });

window.addEventListener("blur", function () {
	if (ig.system) {
		if(ig.game){
			ig.game.font.draw('Game Paused',ig.system.width/2,ig.system.height/2,ig.Font.ALIGN.CENTER);			
		}
		ig.system.stopRunLoop.call(ig.system);
		soundManager.pauseAll();
	}
}, false);

window.addEventListener("focus", function () {
	if (ig.system && gameStarted ) {
		ig.system.startRunLoop.call(ig.system);
		soundManager.resumeAll();
	}
}, false);


});



Page 1 of 1
« first « previous next › last »