def get_bodies_at_pos(self, search_point, include_static=False, area=0.01): """ Check if given point (screen coordinates) is inside any body. If yes, return all found bodies, if not found return False """ sx, sy = self.to_world(search_point) sx /= self.ppm sy /= self.ppm f = area / self.camera.scale_factor AABB = box2d.b2AABB() AABB.lowerBound = (sx - f, sy - f) AABB.upperBound = (sx + f, sy + f) query_cb = Query_CB() self.world.QueryAABB(query_cb, AABB) bodylist = [] for s in query_cb.fixtures: body = s.body if body is None: continue if not include_static: if body.type == box2d.b2_staticBody or body.mass == 0.0: continue if s.TestPoint((sx, sy)): bodylist.append(body) return bodylist