Closed Pattentrick closed 11 years ago
You do need to require the cursor module, i.e. your final code example is correct. The only time Impact scans the files in game/entities is when you are using the level editor, Weltmeister, and it only does that because we tell it to in the Weltmeister config. This is strictly ImpactJS behavior and is unchanged by Impact++.
One thing I'd suggest is to override buildLevel
instead of loadLevel
and call your spawnMouseCursor
method after calling parent. Impact++ makes level loading deferred, so loadLevel
only tells the game that it should switch levels, while buildLevel
actually creates the level and spawns all the entities. This is important later, because Impact++ has built in smooth fade transitions between levels (which you can disable).
Many thanks for your fast anwser and your explanation about how this whole thing works. I accept your suggestion and will use buildLevel
in the future :-)
Hi there,
i have some trouble with the
spawnEntity
method, i think i misunderstand the usage of it. There is an animated „cursor entity“ in my game that replaces the default browser cursor.I have tried to spawn it after the level loads like this:
However i just get the following error: Uncaught Error: Can't spawn entity of type: undefined. It does not exist in namespace 'ig' or 'ig.global'/'window'.
And the error message is right, there is no „EntityCursor“ in ig or ig.global untill i include the module manually like this.
But until now i thought impact will „scan“ all the files located under game → entities and include them for me. So apparently i am doing something wrong :-(
I am stuck on this, as allways your help is highly appreciated!