Jump to content

[Error] TypeError: undefined is not an object ...


Ninjadoodle
 Share

Recommended Posts

Hi @enpu

 

This has been happening in most of the versions until now, including the latest develop.

I'm not too sure whether it's something i'm doing wrong, or something else.

 

Right now, I'm using a commit that fixes the mobile browser fullscreen.

 

It's really strange as it happens rarely and completely randomly (when reloading/testing the game) as far as I can tell.

 

Thank you!

Link to comment
Share on other sites

Hmm just go this error again when refreshing my game ...

 

[Error] TypeError: undefined is not an object (evaluating 'game[extend].extend')

createClass (core.js, line 711)
createScene (core.js, line 721)
(anonymous function) (stage05.js, line 7)
loadModules (core.js, line 424)
body (core.js, line 353)
global code (stage05.js, line 4)
 
not too sure what it means, but I get a white screen and if I reload again, things work normally.
Link to comment
Share on other sites

Hi @enpu

 

Luckily the code is pretty short ... the thing is that it happens randomly (I don't think it's always stage05)

game.module(    'game.stage05').body(function() {// LEVEL CODEgame.createScene('Stage05', {    backgroundColor: 0x000000,    init: function() {    	// SETUP LEVEL        game.storage.set('level', game.system.currentSceneName);        var fader = new game.Fader({color: 0xFFFFFF, speed: 500});        fader.fadeIn();        var bg = new game.Container().addTo(game.scene.stage);        var mg = new game.Container().addTo(game.scene.stage);        var fg = new game.Container().addTo(game.scene.stage);        var ui = new game.Container().addTo(game.scene.stage);        bg.position.set(game.system.width / 2 - game.system.originalWidth * game.scale / 2, game.system.height / 2 - game.system.originalHeight * game.scale / 2);        mg.position.set(game.system.width / 2 - game.system.originalWidth * game.scale / 2, game.system.height / 2 - game.system.originalHeight * game.scale / 2);        fg.position.set(game.system.width / 2 - game.system.originalWidth * game.scale / 2, game.system.height / 2 - game.system.originalHeight * game.scale / 2);        ui.position.set(game.system.width / 2 - game.system.originalWidth * game.scale / 2, game.system.height / 2 - game.system.originalHeight * game.scale / 2);        var buttonOptions = new ButtonOptions(ui);        // SETUP WORLD BG        var worldBg = new game.Sprite('worldBg.png');        worldBg.position.set(240*game.scale, 160*game.scale);        worldBg.anchor.set(0.5, 0.5);        bg.addChild(worldBg);        // SETUP WORLD FG        var worldFg1 = new game.Sprite('worldFg.png');        worldFg1.position.set(240*game.scale, 160*game.scale);        worldFg1.anchor.set(0.5, 0.5);        fg.addChild(worldFg1);        var worldFg2 = new game.Sprite('worldFg.png');        worldFg2.position.set(240*game.scale, 160*game.scale);        worldFg2.anchor.set(0.5, 0.5);        fg.addChild(worldFg2);        // SETUP CLUES        var clue1 = new game.Sprite('clueCompass1a.png');        clue1.anchor.set(0.5, 0);        clue1.position.set(112*game.scale, 64*game.scale);        mg.addChild(clue1);        var clue2 = new game.Sprite('clueCompass1b.png');        clue2.anchor.set(0.5, 0);        clue2.position.set(368*game.scale, 64*game.scale);        mg.addChild(clue2);        // SETUP SWITCHES        var lightswitch1 = game.Animation.fromFrames('lightswitchCompass');        lightswitch1.anchor.set(0.5, 0);        lightswitch1.position.set(120*game.scale, 208*game.scale);        lightswitch1.interactive = true;        lightswitch1.buttonMode = true;        mg.addChild(lightswitch1);        var lightswitch2 = game.Animation.fromFrames('lightswitchCompass');        lightswitch2.anchor.set(0.5, 0);        lightswitch2.position.set(200*game.scale, 208*game.scale);        lightswitch2.interactive = true;        lightswitch2.buttonMode = true;        mg.addChild(lightswitch2);        var lightswitch3 = game.Animation.fromFrames('lightswitchCompass');        lightswitch3.anchor.set(0.5, 0);        lightswitch3.position.set(280*game.scale, 208*game.scale);        lightswitch3.interactive = true;        lightswitch3.buttonMode = true;        mg.addChild(lightswitch3);        var lightswitch4 = game.Animation.fromFrames('lightswitchCompass');        lightswitch4.anchor.set(0.5, 0);        lightswitch4.position.set(360*game.scale, 208*game.scale);        lightswitch4.interactive = true;        lightswitch4.buttonMode = true;        mg.addChild(lightswitch4);        // SETUP LIGHTBULB        var lightbulb = new game.Container().addTo(game.scene.stage);        lightbulb.position.set(240*game.scale, -80*game.scale);        mg.addChild(lightbulb);        var lightbulbLight = new game.Sprite('lightbulbLight.png');        lightbulbLight.anchor.set(0.5, 0.5);        lightbulbLight.position.set(0*game.scale, 188*game.scale);        lightbulbLight.alpha = 0;        lightbulb.addChild(lightbulbLight);        var lightbulbHead = new game.Sprite('lightbulbHead.png');        lightbulbHead.anchor.set(0.5, 0.5);        lightbulbHead.position.set(0*game.scale, 188*game.scale);        lightbulb.addChild(lightbulbHead);        var lightbulbHead2 = new game.Sprite('lightbulbHead2.png');        lightbulbHead2.anchor.set(0.5, 0.5);        lightbulbHead2.position.set(0*game.scale, 188*game.scale);        lightbulbHead2.alpha = 0;        lightbulb.addChild(lightbulbHead2);        var lightbulbHighlight = new game.Sprite('lightbulbHighlight.png');        lightbulbHighlight.anchor.set(0.5, 0.5);        lightbulbHighlight.position.set(0*game.scale, 188*game.scale);        lightbulb.addChild(lightbulbHighlight);        var lightbulbEye1 = new game.Sprite('lightbulbEye.png');        lightbulbEye1.anchor.set(0.5, 0.5);        lightbulbEye1.position.set(-28*game.scale, 208*game.scale);        lightbulb.addChild(lightbulbEye1);        var lightbulbEye2 = new game.Sprite('lightbulbEye.png');        lightbulbEye2.anchor.set(0.5, 0.5);        lightbulbEye2.position.set(28*game.scale, 208*game.scale);        lightbulb.addChild(lightbulbEye2);        var lightbulbMouth = new game.Sprite('lightbulbMouth.png');        lightbulbMouth.anchor.set(0.5, 0);        lightbulbMouth.position.set(0*game.scale, 208*game.scale);        lightbulb.addChild(lightbulbMouth);        var lightbulbSocket = new game.Sprite('lightbulbSocket.png');        lightbulbSocket.anchor.set(0.5, 0);        lightbulbSocket.position.set(0*game.scale, 0*game.scale);        lightbulb.addChild(lightbulbSocket);        // FUNCTIONS        lightswitch1.click = lightswitch1.tap = function(event) {        	game.audio.playSound('click');            if (event.target.currentFrame < 3) {                event.target.gotoAndStop(event.target.currentFrame + 1);            } else {                event.target.gotoAndStop(0);            }        	lightCheck();         }        lightswitch2.click = lightswitch2.tap = function(event) {        	game.audio.playSound('click');            if (event.target.currentFrame < 3) {                event.target.gotoAndStop(event.target.currentFrame + 1);            } else {                event.target.gotoAndStop(0);            }        	lightCheck();         }        lightswitch3.click = lightswitch3.tap = function(event) {        	game.audio.playSound('click');            if (event.target.currentFrame < 3) {                event.target.gotoAndStop(event.target.currentFrame + 1);            } else {                event.target.gotoAndStop(0);            }        	lightCheck();         }        lightswitch4.click = lightswitch4.tap = function(event) {        	game.audio.playSound('click');            if (event.target.currentFrame < 3) {                event.target.gotoAndStop(event.target.currentFrame + 1);            } else {                event.target.gotoAndStop(0);            }        	lightCheck();         }        lightCheck = function() {        	if (lightswitch1.currentFrame == 0 && lightswitch2.currentFrame == 1 && lightswitch3.currentFrame == 3 && lightswitch4.currentFrame == 2) {        		game.audio.playSound('harpPass');        		lightswitch1.interactive = false;                lightswitch1.buttonMode = false;                lightswitch2.interactive = false;                lightswitch2.buttonMode = false;                lightswitch3.interactive = false;                lightswitch3.buttonMode = false;                lightswitch4.interactive = false;                lightswitch4.buttonMode = false;        		game.scene.addTween(lightbulbHead2, {alpha:1}, 100, {delay:0}).start();	            game.scene.addTween(lightbulbLight, {alpha:0.1}, 250, {delay:0, easing:'Quadratic.Out'}).start();	            game.scene.addTween(lightbulbLight, {rotation:Math.PI * -2}, 4000, {delay:0}).repeat().start();	            game.scene.addTween(worldFg2, {alpha:0}, 250, {delay:0}).start();	            var lightbulbSquash = function() {                    game.scene.addTween(lightbulbEye1, {y:224*game.scale}, 100, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye2, {y:224*game.scale}, 100, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye1.scale, {x:1.5, y:0.2}, 100, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye2.scale, {x:1.5, y:0.2}, 100, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbMouth, {y:224*game.scale}, 100, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbMouth.scale, {x:1.25, y:0.2}, 100, {delay:0, easing:'Quadratic.Out', onComplete:lightbulbStretch}).start();                }                var lightbulbStretch = function() {                    lightbulbMouth.setTexture('lightbulbMouth2.png');                    game.scene.addTween(lightbulbEye1, {y:208*game.scale}, 200, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye2, {y:208*game.scale}, 200, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye1.scale, {x:1, y:1}, 200, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbEye2.scale, {x:1, y:1}, 200, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbMouth, {y:208*game.scale}, 200, {delay:0, easing:'Quadratic.Out'}).start();                    game.scene.addTween(lightbulbMouth.scale, {x:1, y:1}, 200, {delay:0, easing:'Quadratic.Out', onComplete:nextStage}).start();                }                lightbulbSquash();        	}        }        nextStage = function() {        	fader.fadeOut(function() {            	game.system.setScene('Stage06');            });        }    }});});
Link to comment
Share on other sites

Hi @enpu

 

Ok I see, I always separate my levels into modules and didn't know about this. I guess if things don't load in the correct order, it would cause a white screen/crash!

 

Thanks heaps for explaining this! I will go and fix my levels now haha (pretty easy fix)!

Link to comment
Share on other sites

I just pushed changes to core, so that now every game module requires core module automatically (before it was only the main game module).

So there is no need to require engine modules (like engine.scene) in your game modules anymore (because core module requires them).

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...