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 Seeders

Everywhere I try to find how to query for entities in my world, people say use the world.QueryAABB(callback,aabb), but box2djs doesn't seem to have that.

All I seem to have is
 ig.world.Query =  function (b,c,d){var e=new Array(d);b=this.m_broadPhase.QueryAABB(b,e,d);for(d=0;d<b;++d)c[d]=e[d];return b}

Which I can't get to return anything but 0.
    var aabb = new b2.AABB();
	aabb.lowerBound.Set(this.pos.x - 50, this.pos.y - 50);
	aabb.upperBound.Set(this.pos.x + 50, this.pos.y + 50);
	var myArray = new Array(10);
	var entitiesInRange = ig.world.Query(aabb, myArray, 10);

entitiesInRange is 0. And even if it was non-zero, how would I have access to the bodies found in the query? Would they be in my array? Why do I have to set a maxCount? This function just doesn't make any sense to me..

1 decade ago by quidmonkey

All Impact entities are stored in the ig.game.entities array, even if you use the Box2D plugin. So use getEntitiesByType() & getEntityByName().
Page 1 of 1
« first « previous next › last »