def follow(self, game_loop=None, first=False):
"""
Helper method to follow our self.obj_to_follow (should not be called by the API user).
Called when the Stage triggers Event 'post_tick' (passes GameLoop into it which is not used).
:param GameLoop game_loop: the GameLoop that's currently playing
:param bool first: whether this is the very first call to this function (if so, do a hard center on, otherwise a soft-center-on)
"""
follow_x = self.directions["x"](self.obj_to_follow) if callable(self.directions["x"]) else self.directions["x"]
follow_y = self.directions["y"](self.obj_to_follow) if callable(self.directions["y"]) else self.directions["y"]
func = self.center_on if first else self.soft_center_on
func(self.obj_to_follow.rect.centerx if follow_x else None, self.obj_to_follow.rect.centery if follow_y else None)
评论列表
文章目录