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())
def __init__(self, planet, image, name, scale=1, gravity=False, angle=0, distance=0, collision_type=TAG.BUILDING): super(Building, self).__init__(planet=planet, scale=scale, image=image, name=name, gravity=gravity, angle=angle, distance=distance, collision_type=collision_type) points = [(-self.width / 2, -self.height / 2), (-self.width / 2, self.height / 2), (self.width / 2, self.height / 2), (self.width / 2, -self.height / 2)] self.shape = pymunk.Poly(self.body, points) self.shape.collision_type = collision_type self.shape.object = self self.name_label = cocos.text.RichLabel(self.name, position=(0, self.height / 2), anchor_x="center", anchor_y="center", font_size=9) self.add(self.name_label, z=10000) self.name_label.do(FadeOut(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(FadeOut(10))
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]))
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))
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
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))
def add_damage_label(self, damage, position): label = cocos.text.Label( '-' + str(int(round(damage))), font_name='Helvetica', font_size=10, bold=True, color=(255, 0, 0, 255), anchor_x='center', anchor_y='center' ) label.deleteWhenHided = True label.position = position label.do(MoveBy((0, 100), 2) | FadeOut(2)) self.globalPanel.add(label)
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))
def on_previous(self): for section in reversed(self.expose_text_runs): if not section['on']: continue section['on'] = False if section['style'] == 'fade': self.do(FadeOut(.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, 0) for s, e, color in section['runs']: color = color[:3] + (0, ) self.document.set_style(s, e, dict(color=color)) self.text_layout.end_update() return pyglet.event.EVENT_HANDLED
def intro_train_start(self, event): self.background.do(FadeOut(duration=20)) self.unschedule(self.intro_train_start)
def hide_name(self): self.name_label.do(FadeOut(0.15))
def hide(self): self._inner_node.do(FadeOut(1))
def hide(self): self.label.do(FadeOut(1))