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 MyShuitings

This is driving me insane.

I've got the level change entity with the following settings:
level: two
name:leveltwo

and a trigger with target.1: leveltwo

When it triggers I am getting an error in game.js line 36 where it tries to access the level and get the entities.

Now, I've made sure that in main.js I am loading the level as such: 'game.levels.two', and if I use firebug I can see the object in the DOM... but when the loadLevel tries to call it from when the game is already running I get this error. (I tried binding F2 to call it by hand, and no dice). I can load that level directly as the first level in main.js... but get errors when I try to load any subsequent level... I even went to the extreme of copying the code from game.js and trying to run it by hand on a key press... same error.

Has anyone else ran into this or similar issue?

Below is the nasty error:

Uncaught TypeError: Cannot read property 'length' of undefined
ig.Game.ig.Class.extend.loadLevel game.js:36
EntityPlayer.ig.Entity.extend.update player.js:101
window.ig.Class.extend.prototype impact.js:358
ig.Game.ig.Class.extend.update game.js:144
MyGame.ig.Game.extend.update main.js:86
window.ig.Class.extend.prototype impact.js:358
ig.Game.ig.Class.extend.run game.js:128
ig.System.ig.Class.extend.run system.js:98
(anonymous function) impact.js:52

1 decade ago by fugufish

hmm works fine for me

here's what i have

// in main.js

.requires(
   	'game.levels.level2',
	'game.levels.level1',
        'game.entities.levelchange'
)



in weltmeister, level 1:

* trigger entity *
target.1 : nextLevel


* LevelChange entity *
name: nextLevel
level: leveltwo

and there's the white line connecting both entities.

hope it helps

1 decade ago by fugufish

whoops sorry, "leveltwo" should be "level2"

1 decade ago by MyShuitings

Thanks Fugu... but no dice...

Hmm... Weltmeister for me sets if up all perfectly, ie the two entities are linked like they should be with the white line... the issue is that when the level change entity is called... it creates 'Level'+REGEXMAGIC and passes that to LoadLevel.

When I go into game.js and add a console.log(data) of the LoadLevel function, I get the correct name of the level but as plaintext. And then when the code tries to access data.entities it throws an undefined error.

I can however use console and type "LevelTwo.entities" and it shows me the objects, but when the code attemps data.entities it dies on me....

I am testing in Chrome and Firefox in Ubuntu. Would baking a version and posting it help trouble shoot this?

1 decade ago by fugufish

hmm don't bake it, it hurts the eye to read baked stuff

posting a zipped version of the entire directory on a filehosting service would be good ( eg: hotfile, fileserve, etc)

1 decade ago by dominic

Try to add some debug output to the levelchange.js. E.g. just before the call to ig.game.loadLevel(), do this:
console.log( levelName );
console.log( ig.global['Level'+levelName] );

It should report the name you supplied, but with an uppercase first letter and the object with the name 'Level'+name with all its entities and layers. So in your case 'Two' and the object LevelTwo.


Also, one minor thing I just noticed: the levelchange entity from the Entity Pack still used ig.game.loadLevel() instead of the new ig.game.loadLevelDeferred(). So change this line:
ig.game.loadLevel( ig.global['Level'+levelName] ); // old
ig.game.loadLevelDeferred( ig.global['Level'+levelName] ); // new

I also updated it in the Entity Pack ZIP file.

1 decade ago by MyShuitings

You're a wizard Dom... the console.logs I had already tried but the real issue seems to be me being a complete and utter moron.

I had replaced ig.global['Level'+levelName] with 'Level'+levelName so of course I was only passing the text name of the level instead of the object.

I've officially decided not to code past 4 in the morning, and definitely not to post to the forum if I get stuck at that time.

Thanks Fugu and Dom for the help...

1 decade ago by MobileMark

Just a side note, MikeL made an amazing plugin module for level loading in sequence.

you can find it here or in the code section of this forum under Director Plugin

https://github.com/boneheadmed/Director

1 decade ago by MyShuitings

Yeah, I'm using it. I had an the same error with it as with straight loadLevel... but due to the same stupidity. Once I fixed the vanilla loadLevelDefferred I then went back and turned the levelchange entity to use the Director plugin.
Page 1 of 1
« first « previous next › last »