__init__.py 文件源码

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

项目:spygame 作者: sven1977 项目源码 文件源码
def lock_ladder(self):
        """
        Locks the GameObject into a ladder.
        Makes sure that there is nothing in the x-way (to move to the center of the ladder if standing a little bit aside). Otherwise, will not lock.
        """
        obj = self.game_object

        # test x-direction after corrective x-move to center of ladder (if there is something, don't lock)
        #obj.stage.locate()

        self.on_ladder = self.touched_ladder
        # switch off gravity
        self.gravity = False
        # lock obj to center of ladder (touched_ladder is always set to the one we are touching right now)
        obj.rect.centerx = self.touched_ladder.rect.centerx
        self.vx = 0  # stop x-movement
        # undock all objects currently docked to us (if any)
        self.game_obj_cmp_dockable.undock_all_docked_objects()
        # store the type before it locked to the ladder and remove the dockable/one-way-platform types (if set)
        self.type_before_ladder = obj.type
        obj.type &= ~Sprite.get_type("one_way_platform,dockable")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号