setWorld method
Change the world
Implementation
@override
void setWorld(World world) {
// Clear the old axis array
axisList.clear();
// Add all bodies from the new world
for (int i = 0; i < world.bodies.length; i++) {
axisList.add(world.bodies[i]);
}
// Remove old handlers, if any
world.removeEventListener('addBody', _addBodyHandler);
world.removeEventListener('removeBody', _removeBodyHandler);
// Add handlers to update the list of bodies.
world.addEventListener('addBody', _addBodyHandler);
world.addEventListener('removeBody', _removeBodyHandler);
this.world = world;
dirty = true;
}