def playeffect(soundfile): """播放音效""" config.read('config.ini', encoding='utf-8') # 读取音效状态 soundstatus = config.getint('setting', 'sound_status') if soundstatus == 1: effect = Effect(RES_PATH + soundfile) effect.play()
def stop_prize(self): self.alread_get_prize.append(self.current_num) self.is_begin = False effect = Effect('2.wav') effect.play() self.top_notice.element.text = "" self.pressbgsprite.do(Hide()) self.bgsprite.do(Show()) self.unschedule(self.rotate_select)
def on_set_item_callback(self): print("call on_set_item_callback") effect = Effect('sound/Blip.wav') effect.play() # new_scene = Setting.create_scene() # director.push(new_scene) new_scene = Setting.create_scene() # dst = RotoZoomTransition(new_scene, 1.2) # dst = JumpZoomTransition(new_scene, 1.2) dst = SlideInLTransition(new_scene, 1.2) director.push(dst)
def frame(self, dt): if not self.monsters or not self.projectiles: pass proj_delete = [] mons_delete = [] for projectile in self.projectiles: for monster in self.monsters: rect_proj = projectile.get_rect() rect_mons = monster.get_rect() if rect_proj.intersects(rect_mons): proj_delete.append(projectile) mons_delete.append(monster) self.monsters.remove(monster) self.projectiles.remove(projectile) self.remove(monster) self.remove(projectile) print 'pang!' effect = Effect('powerup.wav') effect.play() del proj_delete del mons_delete
def rotate_select(self, dt): if (self.current_num >= 24): self.current_num = 0 self.prize_cycle += 1 if (self.prize_cycle > 1 and self.can_stop): if (not self.start_slow): # 减速 self.unschedule(self.rotate_select) self.schedule_interval(self.rotate_select, self.prize_speed_slow) self.start_slow = True # print self.alread_get_prize # print "stopnum" , self.stop_num # print "prize_cycle" , self.prize_cycle # print "current_num" , self.current_num # print self.current_num # 注意rotate_select是要两个参数的 self.sprite.rotation = self.sprite.rotation + 15 self.alread_prize_sprite.rotation = self.alread_prize_sprite.rotation + 15 if self.current_num in self.alread_get_prize: self.sprite.do(Hide()) self.alread_prize_sprite.do(Show()) else: self.alread_prize_sprite.do(Hide()) self.sprite.do(Show()) effect = Effect('1.wav') effect.play() if (self.prize_cycle > 2 and self.stop_num == self.current_num and self.can_stop): self.stop_prize() return True self.current_num += 1
def __init__(self,image,pos,patEnd): self.noise = 0 self.lastKnownLoc = [] #when set, will goto here when investigating self.patA = pos self.patB = patEnd self.bState = 'looking' self.shootTimer = 100; self.controlled = False self.alertSound = Effect('Alert.wav') super(BasicEnemy,self).__init__(image,pos,16) self.team = 1 for a in g.team[self.team]: self.push_handlers(a)#a should recieve my events a.push_handlers(self)#I should receive a's events g.team[self.team].add(self) self.addSkill(SpearThrow()) self.curMov = self.do(Patrol(self.patB,self.patA,self.noise))
def main(): director.init(audio_backend='sdl') effect = Effect('powerup.wav') effect.play() import time time.sleep(2)
def menu_start_callback(self): yinxiao = Effect('sound/Blip.wav') # 音效 yinxiao.play() pass
class BasicEnemy(Being,EventDispatcher): def __init__(self,image,pos,patEnd): self.noise = 0 self.lastKnownLoc = [] #when set, will goto here when investigating self.patA = pos self.patB = patEnd self.bState = 'looking' self.shootTimer = 100; self.controlled = False self.alertSound = Effect('Alert.wav') super(BasicEnemy,self).__init__(image,pos,16) self.team = 1 for a in g.team[self.team]: self.push_handlers(a)#a should recieve my events a.push_handlers(self)#I should receive a's events g.team[self.team].add(self) self.addSkill(SpearThrow()) self.curMov = self.do(Patrol(self.patB,self.patA,self.noise)) def on_alert(self,ally): '''respond to an ally becoming alert''' if self.bState == 'looking': self.bState = 'investigating' self.lastKnownLoc = ally.position print 'your alert!' def update(self,dt): super(BasicEnemy,self).update(dt) if self.bState == 'alert': self.alertSound.play() self.stop() #shoot fancyAction = self.do(ShootAtEnemy(50)) fancyAction.initVars(g.player) #follow fancyMove = self.do(FollowBeing()) fancyMove.initVars(g.player) self.bState = 'attacking' self.dispatch_event('on_alert',self) elif self.bState == 'attacking': self.lastKnownLoc = g.player.position elif self.bState == 'unalert': self.stop() if self.lastKnownLoc: self.bState = 'investigating' self.curMov = self.do(MyMoveTo(self.lastKnownLoc,self.noise)) print 'investigating!' else: self.bState = 'uninvestigate' elif self.bState == 'investigating': if self.curMov.done(): print 'I give up...' self.lastKnownLoc = [] self.bState = 'uninvestigate' elif self.bState == 'uninvestigate': self.stop() #go back to patrol route print 'back to the ole route' self.bState = 'looking' self.curMov = self.do(Patrol(self.patB,self.patA,self.noise)) if self.state == 'take_control': print 'im being controled :-(' self.controlled = True self.state = 'norm' self.stop() self.do(ActorController()) elif self.state == 'release_control': self.controlled = False self.state = 'norm' self.stop() self.do(RandomController()) def takeHit(self,damage): super(BasicEnemy,self).takeHit(damage) if self.bState == 'looking': self.bState = 'investigating'
def on_start_item_callback(self): print("call on_start_item_callback") effect = Effect('sound/Blip.wav') effect.play()
def on_on_up_callback(self): effect = Effect('sound/Blip.wav') effect.play() director.pop()
def on_options(self): self.parent.switch_to(1) risada = Effect("risada.wav") risada.play()