refactoring of addEntity in b2dengine