Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- from scene import *
- class ButtonLayout (Node):
- def __init__(self, **kwargs):
- Node.__init__(self, position=(0, 0), **kwargs)
- self.z_position = 2
- self.left_button = SpriteNode('iow:arrow_left_c_256', position=(100, 100), scale=.6, parent=self)
- self.right_button = SpriteNode('iow:arrow_right_c_256', position=(260, 100), scale=.6, parent=self)
- self.jump_button = SpriteNode('iow:ios7_circle_filled_256', position=(900, 100), scale=.5, parent=self)
- self.direction_pressed = None
- self.action_pressed = False
- self.direction_times_pressed = 0
- self.frames_until_zero_button_press = 0 #goes up to 30
- def left_button_pressed(self):
- self.direction_pressed = 'left'
- self.direction_times_pressed +=1
- self.left_button.color = '#d30000'
- self.right_button.color = '#ffffff'
- def right_button_pressed(self):
- self.direction_pressed = 'right'
- self.direction_times_pressed +=1
- self.right_button.color = '#d30000'
- self.left_button.color = '#ffffff'
- def jump_button_pressed(self):
- self.action_pressed = True
- self.jump_button.color = '#41c824'
- def jump_not_pressed(self, touch):
- self.action_pressed = False
- self.jump_button.color = '#ffffff'
- def direction_not_pressed(self):
- self.left_button.color = '#ffffff'
- self.right_button.color = '#ffffff'
- self.direction_pressed = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement