Пример #1
0
    def __init__(self):
        super().__init__()
        width, height = director.get_window_size()

        # particle effect
        pe = Fireworks()

        pe.position = (width // 2, 80)
        pe.duration = 6
        pe.speed = 260
        pe.size = 10.0
        pe.auto_remove_on_finish = True

        self.add(pe)

        action = Blink(20, 2) + Show()

        # msg1
        msg1 = self.create_text("Congratulations!", 72, width // 2,
                                height // 2)
        msg1.do(action)

        # msg2
        msg2 = self.create_text("You win", 46, width // 2, height // 3)
        msg2.do(action)

        # msg3
        msg3 = self.create_text("press enter back to menu", 32, width // 2, 0)
        msg3.opacity = 0
        msg3.do(FadeIn(2))
    def __init__(self):
        super(LoadingScene, self).__init__()
        # 开启事件处理层 有事件发生 就要写
        cocos.layer.Layer.is_event_handler = True
        d_width, d_height = cocos.director.director.get_window_size()

        # 创建背景精灵
        background = cocos.sprite.Sprite('Resource//loading_scene//background.png')
        background.position = d_width // 2, d_height // 2

        # 创建标题精灵
        title = cocos.sprite.Sprite('Resource//loading_scene//title.png')
        title.position = d_width // 2, d_height // 2

        delay_move_to = Delay(1.0)
        move_to = MoveTo((d_width // 2, d_height // 5 * 3), 2)
        title.do(delay_move_to + move_to)

        sub_title = cocos.sprite.Sprite('Resource//loading_scene//sub_title.png')
        sub_title.position = d_width // 2, d_height // 7 * 3
        sub_title.opacity = 0
        fade_in = FadeIn(2.0)
        delay_fade_in = Delay(2)
        sub_title.do(delay_fade_in + fade_in)

        self.add(background)
        self.add(title)
        self.add(sub_title)
Пример #3
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())
Пример #4
0
 def update_sprite(self, image=None, effect=None):
     if image:
         self.sprite.image = self.resouces['image'][image]
     if effect:
         if effect[0] == 'fade_in':
             self.sprite.do(FadeIn(effect[1]))
         elif effect[0] == 'fade_out':
             self.sprite.do(FadeOut(effect[1]))
Пример #5
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(FadeIn(10))
Пример #6
0
 def update_drink(self, drink):
     """
     Update the drink shown.
     """
     self.label.do(FadeOut(1))
     self.drink = drink
     self._set_label()
     self.label.do(FadeIn(1))
Пример #7
0
 def click(self, x, y):
     # validate positions
     for i, (pos_x, pos_y) in enumerate(self.positions):
         ok_x = pos_x - 5 <= x <= pos_x + 5
         ok_y = pos_y - 5 <= y <= pos_y + 5
         if ok_x and ok_y:
             sprite = self.sprites[i]
             sprite.do(FadeOut(.5) + FadeIn(.5))
             break
Пример #8
0
 def update(self, new_node):
     """
     Update the drink shown.
     """
     self._inner_node.do(FadeOut(0.5))
     self._inner_node = new_node
     new_node.opacity = 0
     self.add(new_node, z=self._next_z_level)
     self._next_z_level += 1
     self._inner_node.do(FadeIn(0.5))
Пример #9
0
 def add_new_infos(self, content, color=(0, 255, 0, 255)):
     if self.info.full():
         obj_leave = self.info.get()
         obj_leave.do(
             MoveTo((self.width // 2, self.height), 1) | FadeOut(1))
     for obj in self.info.queue:
         obj.do(MoveBy((0, 40), 1))
     obj = Text(text=content,
                position=(self.width // 2, self.height // 2 + 50),
                color=color,
                font_size=30)
     self.add(obj)
     self.info.put(obj)
     obj.do(FadeIn(1.5) + CallFunc(self.get_next_action))
Пример #10
0
    def __init__(self, blackboard):
        super(Boid, self).__init__(self._img)
        self.scale = 0.05
        self.schedule(self.update)
        self.bb = blackboard
        self.boids.append(self)
        self.opacity = 0
        self.do(FadeIn(2))
        self.speed = 200
        self.bounding_radius = 5
        self.bounding_radius_squared = 25
        self.neighborhood_radius = 1000
        self.personal_radius = 20

        self.tree = self.buildTree()
Пример #11
0
 def on_next(self):
     for section in self.expose_text_runs:
         if section['on']: continue
         section['on'] = True
         if section['style'] == 'fade':
             self.do(FadeIn(.5),
                     FadeSection(self.text_layout, self.document, section))
         else:
             self.text_layout.begin_update()
             for element in section['elements']:
                 element.set_opacity(self.text_layout, 255)
             for s, e, color in section['runs']:
                 self.document.set_style(s, e, dict(color=color))
             self.text_layout.end_update()
         return pyglet.event.EVENT_HANDLED
Пример #12
0
 def show_name(self):
     self.name_label.do(FadeIn(0.15))