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())
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, image, pos, maplayer): super().__init__(image, pos, maplayer) self.velocity = (50, 0) self.visible = False self.do(Delay(0.3) + Show() + ShowProp() + MoveActor())
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
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
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
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
def __init__(self): super(TestLayer, self).__init__() x, y = director.get_window_size() self.sprite = Sprite('grossini.png', (x / 2, y / 2)) self.sprite.visible = False self.add(self.sprite) self.sprite.do(Show())
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
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())
def make_visible(sp): sp.do(Show())
def show_msg(self, msg): self.msg.element.text = msg self.msg.do(Show() + Delay(1) + Hide())
def update_lifebar(self, dt): for i in self.lifebar_list: i.do(Hide()) self.lifebar_list[3 - self.durability].do(Show())
def __init__(self, pos, _): super().__init__(Image.fire_flower_blink, pos, _) self.visible = False self.do(Delay(0.3) + Show() + ShowProp())