-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_action.py
36 lines (26 loc) · 1021 Bytes
/
user_action.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from kivy.uix.relativelayout import RelativeLayout
def keyboard_closed(self):
self._keyboard.unbind(on_key_down=self.on_keyboard_down)
self._keyboard.unbind(on_key_up=self.on_keyboard_up)
self._keyboard = None
def on_keyboard_down(self, keyboard, keycode, text, modifiers):
if keycode[1] == 'left':
self.current_Speed_x = self.speed_x
elif keycode[1] == 'right':
self.current_Speed_x = -self.speed_x
return True
def on_keyboard_up(self, keyboard, keycode):
self.current_Speed_x = 0
return True
def on_touch_down(self, touch):
if not self.state_game_over and self.state_game_has_started :
if touch.x < self.width / 2:
# print("<--")
self.current_Speed_x = self.speed_x
else:
# print("-->")
self.current_Speed_x = -self.speed_x
return super(RelativeLayout , self).on_touch_down(touch)
def on_touch_up(self, touch):
#print("Up")
self.current_Speed_x = 0