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 fulvio

If I have the following code in an Entity. Whenever I view that level in Weltmeister I get the following error within the Firebug console:
ig.game.getEntitiesByType is not a function

This the code I'm using within the draw method of my HUD entity:

draw: function () {
    this.font.draw('Coins: ' + ig.game.getEntitiesByType(EntityCoin).length + '/' + ig.game.coinCount, 185, 5);
    this.parent();
}

I have tried both ig.game.getEntitiesByType() and this.getEntitiesByType() and neither seem to remove that error.

I have also tried to include game.entities.coin and add it as a module, but the same error pops up in the console.

1 decade ago by Arantor

Well, it won't be loaded at that point.

What you need to do is test for ig.global.wm before trying to draw the entity and then it'll work.

As per http://impactjs.com/forums/help/weltmeister-not-loading-level-when-entities-refer-jquery-objects

Or, of course, you don't have to use an entity for handling the HUD and instead just have it as part of the game object itself...

1 decade ago by fulvio

I've used the following code, thanks!

if (!ig.global.wm) {

}

I did think of putting the HUD within the main draw() method, but I wanted to create it as an entity so then I could detect mouse hover and perhaps add different image elements in the HUD as well.
Page 1 of 1
« first « previous next › last »