__init__.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:spygame 作者: sven1977 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号