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 dmen

I have a snowman entity that is setup like so:


defines(function () {

EntityButtons = ig.Entity.extend({
name: 'buttons1',

init: function(){
etc.

Later, I have a bullet that tries to get this entity in its update function:

ig.log(ig.game.getEntityByName('buttons1'));

All I ever get is undefined.

Anyone?

1 decade ago by alexandre

Your entity's init function requires arguments, declared as "x, y, settings".

Am also assuming that you spawned this entity or that it was embedded in a level file.

Also, if getEntityByName is called early in the game, it is possible that buttons has not yet been instantiated when the bullet already has. You are not calling this from inside Bullet's init function, right? If so, you should move that call to the entity's ready function.

1 decade ago by dmen

So name has to be a property of the settings object? I swear I saw places where it was declared as a name/value pair in the constructor. I'll try passing it in though.
And yeah, I spawn it, and it's called when everything is available.

1 decade ago by dmen

Heh - that works! Thanks again alexandre!
Page 1 of 1
« first « previous next › last »