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 PaulManjarres

Hi, I'm trying to implement a Game Over Screen as a new Game class. In the update method I check for certain conditions and do a call to:

ig.system.setGame(ig.GameOverScreen);

But I'm getting the following errors in the Javascript console:
Uncaught TypeError: Cannot read property 'Z_INDEX' of undefined     (game.js:37)

My main game class is a Box2dGame, and I'm using the map-minifier plugin, don't know if that matters.

The docs says that is safe to call the setGame method wherever in the game, but inside my main game class I'm getting that error always. If I try to set the game over screen from a start screen (another Game class but not box2dgame) it works.

Thanks.

1 decade ago by PaulManjarres

Ok, i believe I reduced the context of the problem. By some unknown reason, I'm getting the error when I enable the map-minifier plugin in the init method of my game class.
init: function() {
        	// Map minifier plugin.
    		ig.MapMinifier.enableForGame();
        	......
    		......
}

Once I add the line to enable the plugin, I cannot call the ig.system.setGame() method.

I modified the map-minifier plugin in the way that says in the forum to be able to use the plugin with Box2d Game class:

if (ig.Box2DGame) ig.Game = ig.Box2DGame;

That line is causing the problem, but if I dont include it, i'll not be able to use the map minifier in my box2d game. How should I modify it to work?

1 decade ago by PaulManjarres

Ok, I solved the problem. Turns out that the line:
if (ig.Box2DGame) ig.Game = ig.Box2DGame;

was breaking the game.

In order to enable the Map-minifier plugin to be used with a Box2d game class I'm doing the next change on the plugin:
ig.MapMinifier.enableForGame = function() {
		if (ig.MapMinifier.isGameEnabled) {
			return;
		}
		ig.MapMinifier.isGameEnabled = true;
		// Select the appropiate class to inject
		var game = ig.Box2DGame ? ig.Box2DGame : ig.Game; 
		game.inject({
			loadLevel: function(level) {
				for (var i = 0; i < level.layer.length; i++) {
					ig.MapMinifier.decompressLayer(level.layer[i]);
				}
				this.parent(level);
			}
		});
	};

With that change I'm able to use the ig.system.setGame() method again.

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