For those who have found this via search, Jacobalbino gives a great answer:
It’s almost never a good idea to use FP.world for anything but actually setting the world. Don’t reference it to do collisions, or to count entities, or to add or remove entities. The only time you should be using it is when you do FP.world = new MyWorld().
So there you have it. Best to avoid it!.. Or is it?
@azrafe7 suggests that
Basically the only thing you should NOT do is using FP.world in your entities/worlds constructor, override Entity.added()/World.begin() and put your code in there instead. Just doing this should solve 99.9% of FP.world-related problems.
@Ultima2876 elaborates on that line of reasoning, proposing:
The rule of thumb: memory allocations = constructor, logic = added() (the same applies to Worlds - memory = constructor, logic = begin()).
Original Message follows
I’m afraid of using FP.world for anything now, because of some debugging messes I got into with calling things in the constructor of a world…
So I’m creating a system of “collision listeners” for everything that reacts to collisions.
lets say we have an auraCollision
listener that checks for any collisons within a certain rectangular distance from the entity
What I am wondering is if the listener should be checking against an “FP.world.collideRect” in a set of screen coordinates, or if I should give the listeners their own entity with its own hitbox.