Пример #1
0
	def set_slide(self, slide, change='normal'):
		self.get('clock').clock_shown(slide.show_clock)
		
		out_layer=self.get('slide')
		in_layer=self.__get_slide_layer(slide)
		try:
			self.remove('temp')
		except Exception:
			pass # no transition running.
		try:
			self.remove('temp_col')
		except Exception:
			pass # no transition running.
		self.remove('slide')

		self.add(out_layer, z=1, name='temp')
		self.add(in_layer, z=0, name='slide')

		transition=config.effect_mapping[change][slide.effect]
		logger.debug("Changing slide with transition: %s", transition)
		if transition == 'tile_swipe':
			out_layer.do(FadeOutBLTiles(grid=(16, 9), duration=1) + Hide() + StopGrid())
		elif transition == 'crossfade':
			out_layer.do(FadeOut(duration=1))
		elif transition == 'fade_red':
			col_layer=ColorLayer(255, 0, 0, 0)
			self.add(col_layer, z=1.1, name='temp_col')
			col_layer.do(FadeIn(duration=0.3)+Delay(0.5)+FadeOut(duration=1.5))
			out_layer.do(Delay(0.3) + Hide())
		else:
			out_layer.do(Hide())
Пример #2
0
 def set_sprite(self, args):
     for i in args:
         sd = Sprite(i)
         sd.do(Hide())
         self.add(sd)
         self.sprite_list.append(sd)
     self.sprite_list[self.direction].do(Show())
Пример #3
0
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (x / 2, y / 2))
        self.add(self.sprite)
        self.sprite.do(Delay(1) + Hide())
Пример #4
0
 def move_left(self, dt):
     '''向左移动'''
     if self.can_move[2] and self.direction == 2:
         self.cshape_x -= 100 * dt
     for i in self.sprite_list:
         i.do(Hide())
     self.sprite_list[2].do(Show())
     self.direction = 2
Пример #5
0
 def move_down(self, dt):
     '''向下移动'''
     if self.can_move[1] and self.direction == 1:
         self.cshape_y -= 100 * dt
     for i in self.sprite_list:
         i.do(Hide())
     self.sprite_list[1].do(Show())
     self.direction = 1
Пример #6
0
 def move_up(self, dt):
     '''向上移动'''
     if self.can_move[0] and self.direction == 0:
         self.cshape_y += 100 * dt
     for i in self.sprite_list:
         i.do(Hide())
     self.sprite_list[0].do(Show())
     self.direction = 0
Пример #7
0
 def move_right(self, dt):
     '''向右移动'''
     if self.can_move[3] and self.direction == 3:
         self.cshape_x += 100 * dt
     for i in self.sprite_list:
         i.do(Hide())
     self.sprite_list[3].do(Show())
     self.direction = 3
Пример #8
0
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (0, y // 2))
        self.add(self.sprite)
        self.sprite.do(MoveBy((x // 2, 0)) + Hide())
Пример #9
0
 def add_lifebar(self):
     p_list = [
         'pic/life01.png', 'pic/life02.png', 'pic/life03.png',
         'pic/life04.png'
     ]
     self.lifebar_list = []
     for i in range(4):
         lifebar = Sprite(p_list[i])
         lifebar.anchor = (0, 0)
         lifebar.scale_x = 3
         lifebar.scale_y = 5
         lifebar.y += 300
         lifebar.do(Hide())
         self.lifebar_list.append(lifebar)
         self.add(lifebar)
     self.lifebar_list[3 - self.durability].do(Show())
Пример #10
0
    def show_message(self, msg, callback=None):
        w, h = director.get_window_size()

        self.msg = Label(msg,
                         font_size=52,
                         font_name='Arial',
                         anchor_y='center',
                         anchor_x='center')
        self.msg.position = (w // 2.0, h)

        self.add(self.msg)

        actions = Accelerate(MoveBy((0, -h / 2.0), duration=0.5)) + \
                  Delay(1) + \
                  Accelerate(MoveBy((0, -h / 2.0), duration=0.5)) + \
                  Hide()

        if callback:
            actions += CallFunc(callback)

        self.msg.do(actions)
Пример #11
0
    def get_move_action(self, action=None):
        x, y = self.position
        y = y + 40
        theLocation = euclid.Vector2(x, y)
        if action == None:
            moveAction = Show()
        else:
            moveAction = action + Show()

        moveAction += MoveTo(theLocation, self.duration / 4)
        x = x + 40
        theLocation = euclid.Vector2(x, y)
        moveAction += MoveTo(theLocation, self.duration / 4)
        y = y - 40
        theLocation = euclid.Vector2(x, y)
        moveAction += MoveTo(theLocation, self.duration / 4)
        x = x - 40
        theLocation = euclid.Vector2(x, y)
        moveAction += MoveTo(theLocation, self.duration / 4)
        moveAction += Hide()

        return moveAction
Пример #12
0
 def show_msg(self, msg):
     self.msg.element.text = msg
     self.msg.do(Show() + Delay(1) + Hide())
Пример #13
0
 def update_lifebar(self, dt):
     for i in self.lifebar_list:
         i.do(Hide())
     self.lifebar_list[3 - self.durability].do(Show())