def findActorsAt(self, x, y): """Return the actors at a certain location""" actors = actor.ActorCollection() test = geometry.Point(x, y) for the_actor in self.getActors(): if test.isInside(the_actor): actors.append(the_actor) return actors
def getActorsUnderMouse(self, world): """Return all the actors that the mouse is over""" if self._actors_under_mouse is None: x, y = self.getScreenPos() sx, sy = self.getStaticScreenPos() r = self.engine.getRenderer() actors_camera = set([ a for a in world.findActorsAt(x, y) if not r.getLayer(a.layer).static ]) actors_static = set([ a for a in world.findActorsAt(sx, sy) if r.getLayer(a.layer).static ]) # self._actors_under_mouse = actor.ActorCollection( list(actors_static) + list(actors_camera)) # return self._actors_under_mouse
def getActorsUnderMouse(self, world): """Return all the actors that the mouse is over""" if self._actors_under_mouse is None: x, y = self.getScreenPos() sx, sy = self.getStaticScreenPos() r = self.engine.getRenderer() try: actors_camera = set([ a for a in world.findActorsAt(x, y) if not r.getLayer(a.layer).static ]) actors_static = set([ a for a in world.findActorsAt(sx, sy) if r.getLayer(a.layer).static ]) except render.UnknownLayer: raise render.UnknownLayer('Layer "%s" not found for actor %s' % (a.layer, a.getNiceName())) # self._actors_under_mouse = actor.ActorCollection( list(actors_static) + list(actors_camera)) # return self._actors_under_mouse
def getActors(self): """Return all the actors""" actors = actor.ActorCollection(self.unzoned_actors) for z in self.zones: actors.extend(z.getActors()) return actors
def findActorsByTag(self, tag): """Return all the actors in all zones based on the tag""" results = actor.ActorCollection() for z in self.zones: results.extend(z.findActorsByTag(tag)) return results