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 orecrush

I have noticed quite a few threads wondering why getEntityByName always seems to return undefined.

I recently just went through this frustration when I needed to get an entity by name inside of my player entity class. The problem was that I was doing it in the init function. The entity always returned undefined even though when I console.logged the namedEntities variable I could see my entity in the list.

I didn't actually trace back the namedEntities process but I am guessing that since I had put the code in my init function that Impact wasn't done populating that object and so was still being called by a separate function. In my scenario I needed to get a entity to warp my player to a location when he changed levels. The solution was to put it in the update function instead since all of the entities had been instantiated.

Long story short: don't expect getEntityByName to work inside an entities' init function or for namedEntities to be 100% accurate.

1 decade ago by alexandre

Entity init is called for each entity once, as it is spawned. Searching for other entities at this point is therefore not guaranteed to return something useful given that those--the entities you are searching for--may not already have been spawned.

Entity.ready is the function you need to call from inside an entity, as it only gets called once all entities in the game have been spawned.

1 decade ago by orecrush

Isn't that what I said? lol

Thanks for the ready tip though. I'll use that.

1 decade ago by linlan1989

[url=http://www.chiflatironofficial.us]chi flat iron[/url]
[url=http://www.chiflatironofficial.us]chi hair straightener[/url]
[url=http://www.chiflatironofficial.us]chi flat iron official website[/url]
[url=http://rosetta-stone-spanish.weebly.com]rosetta stone spanish[/url]
[url=http://chi-hair-straighteners.weebly.com]CHI hair straightener[/url]
[url=http://www.cagoose.us]Ca Goose products[/url]

1 decade ago by linlan1989

<a href="http://www.chiflatironofficial.us/">chi flat iron</a>
<a href="http://www.chiflatironofficial.us/">chi hair straightener</a>
<a href="http://www.chiflatironofficial.us/">chi flat iron official website</a>
<a href="http://rosetta-stone-spanish.weebly.com/">rosetta stone spanish</a>
<a href="http://chi-hair-straighteners.weebly.com/">CHI hair straightener</a>
<a href="http://www.cagoose.us/">Ca Goose products</a>
Page 1 of 1
« first « previous next › last »