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 potan

I have entity that use getEntitiesByType on init, because i thought calling getEntitiesByType on every frame is not cost effective, so i'd rather call it once in init.

But weltmeister will throw this error when i load the level with this entity.

my code on init:
this.mPlayer = ig.game.getEntitiesByType( EntityPlayer );

Error message:
lib/game/entities/monster.js:38Uncaught TypeError: Object [object Object] has no method 'getEntitiesByType'

Everytime i need to load my level I have to comment the getEntitiesByType, so that it works correctly on weltmeister.

any other solution ?

1 decade ago by Jerczu

The same happens if you try play sound on init just comment it out or move to update.

1 decade ago by dominic

When you run Weltmeister, ig.game is actually set to the wm.Weltmeister instance, instead of a ig.Game instance. It doesn&039;t have the #getEntitiesByType() method.

Also, Weltmeister calls the init() and draw() method for each entity, so you have to make sure there, to guard stuff that should only run in the actual game with an if-statement:

if( !ig.global.wm ) {
    // Do something only when NOT running in Weltmeister
}

1 decade ago by potan

awesome, that works great.

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