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 SnakePlissken

So I am getting a very interesting error in the level editor. When trying to edit a level i get this

ig.game.spawnEntity(EntityHealthBar,this.pos.x , this.pos.y,{ Unit: this });

Uncaught TypeError: Object [object Object] has no method 'spawnEntity'

However when I load my game I get no error and everything runs just fine?

So far I just comment this section of code when I want to edit and it works however I would like to know what is causing this?

Thanks,

Snake

1 decade ago by Arantor

Well, what does EntityHealthBar inherit from?

1 decade ago by SnakePlissken

Only inherits from ig.Entity

using the extend message like this

ig.Entity.extend({
// MY CODE
})

1 decade ago by Arantor

Oh... I was asleep when reading that before.

The class that Weltmeister uses to replace ig.game is not a standard ig Game object, so it doesn't have methods like spawnEntity.

You can hack them into weltmeister.js, or check that window.wm is defined before calling that line of code.

1 decade ago by dominic

You probably don't want to spawn that health bar when you're in the editor!?

if( !ig.global.wm ) { // Not in WM?
	ig.game.spawnEntity(EntityHealthBar,this.pos.x , this.pos.y,{ Unit: this })
}

1 decade ago by SnakePlissken

thanks for the quick fix dominic worked like a charm.
Page 1 of 1
« first « previous next › last »