main.py 文件源码

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

项目:OpenTheDoor 作者: jalnanco 项目源码 文件源码
def on_touch_up(self, touch):
        if touch.grab_current is self:
            x, y = self.tpos
            diff_x = touch.x - x
            diff_y = touch.y - y
            space = 20
            if self.backgroundscreen:
                # if (diff_x  > space):
                #     self.backgroundscreen.center_x = touch.x
                # elif (diff_x < -space):
                #     self.backgroundscreen.center_x = touch.x
                if (diff_y > space):
                    self.backgroundscreen.y = touch.y
                    # ? ??? ???
                    app.game.door.door_down()
                    # up animation
                    self.backgroundscreen.opacity = 0
                    self.backgroundscreen.y = self.y
                    anim = Animation(center_y=self.center_y, duration=.2)
                    anim &= Animation(opacity=1, duration=.2)
                    if anim:
                        anim.stop(self)
                    anim.start(self.backgroundscreen)
                    self.backgroundcolor = random.random(
                    ), random.random(), random.random(), .5

                elif (diff_y < -space):
                    self.backgroundscreen.y = touch.y
                    app.game.door.door_up()

                    # down animation
                    self.backgroundscreen.opacity = 0
                    self.backgroundscreen.top = self.top
                    anim = Animation(center_y=self.center_y, duration=.2)
                    anim &= Animation(opacity=1, duration=.2)
                    if anim:
                        anim.stop(self)
                    anim.start(self.backgroundscreen)
                    self.backgroundcolor = random.random(
                    ), random.random(), random.random(), .5

                else:
                    self.backgroundscreen.center_x = self.center_x
                    self.backgroundscreen.center_y = self.center_y
            touch.ungrab(self)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号