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)
评论列表
文章目录