Advertisement
Guest User

Untitled

a guest
May 30th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # coding: utf-8
  2. from scene import *
  3.  
  4. class ButtonLayout (Node):
  5. def __init__(self, **kwargs):
  6. Node.__init__(self, position=(0, 0), **kwargs)
  7. self.z_position = 2
  8. self.left_button = SpriteNode('iow:arrow_left_c_256', position=(100, 100), scale=.6, parent=self)
  9. self.right_button = SpriteNode('iow:arrow_right_c_256', position=(260, 100), scale=.6, parent=self)
  10. self.jump_button = SpriteNode('iow:ios7_circle_filled_256', position=(900, 100), scale=.5, parent=self)
  11. self.direction_pressed = None
  12. self.action_pressed = False
  13. self.direction_times_pressed = 0
  14. self.frames_until_zero_button_press = 0 #goes up to 30
  15.  
  16. def left_button_pressed(self):
  17. self.direction_pressed = 'left'
  18. self.direction_times_pressed +=1
  19. self.left_button.color = '#d30000'
  20. self.right_button.color = '#ffffff'
  21.  
  22. def right_button_pressed(self):
  23. self.direction_pressed = 'right'
  24. self.direction_times_pressed +=1
  25. self.right_button.color = '#d30000'
  26. self.left_button.color = '#ffffff'
  27.  
  28. def jump_button_pressed(self):
  29. self.action_pressed = True
  30. self.jump_button.color = '#41c824'
  31.  
  32. def jump_not_pressed(self, touch):
  33. self.action_pressed = False
  34. self.jump_button.color = '#ffffff'
  35.  
  36. def direction_not_pressed(self):
  37. self.left_button.color = '#ffffff'
  38. self.right_button.color = '#ffffff'
  39. self.direction_pressed = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement