本文整理汇总了Python中sound.play_effect函数的典型用法代码示例。如果您正苦于以下问题:Python play_effect函数的具体用法?Python play_effect怎么用?Python play_effect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了play_effect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: losing
def losing(self):
score_value = int(self.score.text)
sound.play_effect(fail_sound)
self.green_timer_background.fill_color = color3
self.sparkle(color3, self.start.position, image='shp:RoundRect')
for square in self.squares:
if square.star:
square.star_icon.z_position = 1
square.star_icon.run_action(A.sequence(A.scale_to(0, 1), A.remove()))
if square.state == 3:
self.sparkle(color3, square.position, image='shp:RoundRect')
square.state = 0
if square.state == 0:
square.color = color3
try:
square.red_square.run_action(A.remove())
except:
pass
bg_target = choice(self.bg_list).position
square.run_action(A.sequence(A.wait(2),A.group(A.scale_to(0, 3), A.fade_to(0, 2), A.move_to(bg_target[0], bg_target[1], 2, TIMING_SINODIAL)), A.remove()))
self.start.color = color3
self.finish.color = color3
self.score.color = color3
self.backdrop5.color = color3
self.level_label.text = choice(fail_text)
self.move_counters()
self.save(score_value)
for bg in self.bg_list:
bg.color = color3
开发者ID:nake13,项目名称:black-white,代码行数:29,代码来源:black_white.py
示例2: touch_began
def touch_began(self, touch):
# set firing and play sound on two finger touch
if(len(self.touches) == 2 and not(self.firing)):
sound.play_effect('Laser_1')
self.firing = True
self.laser.frame.x = self.ship.frame.x + (self.ship.frame.w / 2) - 3
self.laser.alpha = 1
开发者ID:lemanouche0221,项目名称:Pythonista-Tools,代码行数:7,代码来源:Space+Invaders.py
示例3: touch_began
def touch_began(self, touch):
for key in chain(self.black_keys, self.white_keys):
if key.hit_test(touch):
key.touch = touch
# print(touch.__dict__)
sound.play_effect(key.name)
return
开发者ID:RichardPotthoff,项目名称:myrepo,代码行数:7,代码来源:Weierstrass_piano.py
示例4: touch_ended
def touch_ended(self, node, touch):
if node == self:
return
for square in self.get_children_with_name('*'):
#print(square.name)
if isinstance(square, sk_BoardSquare) and touch in square:
target_fen_loc = square.name
save_fen_loc = node.fen_loc
#node.move() is called on a different thread so it returns None!!!
move_was_made = node.move(target_fen_loc) # always returns None!!
#print('mwm 1', move_was_made) # fails!!
move_was_made = node.fen_loc != save_fen_loc
#print('mwm 2', move_was_made)
if move_was_made:
for piece in self.get_children_with_name('*'):
# remove the killed sk_ChessPiece
if (piece != node
and isinstance(piece, sk_ChessPiece)
and piece.fen_loc == node.fen_loc):
if piece.piece.ptype == 'king':
import dialogs
dialogs.hud_alert('Game over man!')
piece.remove_from_parent()
#import dialogs
#dialogs.hud_alert(str(type(self.view.superview)))
self.view.superview.update_view(node.piece)
node.position = square.position
sound.play_effect('8ve:8ve-tap-professional')
else:
node.position = self.save_position
sound.play_effect('8ve:8ve-beep-rejected')
not_str = '' if move_was_made else 'not '
fmt = '{} at {} was {}moved to square {}\n'
print(fmt.format(node.name, save_fen_loc, not_str, square.name))
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:34,代码来源:SkChessBoardScene.py
示例5: draw
def draw ( self ):
# 毎回、描画しないと通ったところに色が残ってしまう
background(1, 1, 1)
fill(1, 0, 0)
g = gravity ()
self.x += g.x * 100
self.y += g.y * 100
self.x = min ( self.size.w - 40, max( 0, self.x ))
self.y = min ( self.size.h - 40, max( 0, self.y ))
# 動く四角を描画
image('_Image_1', self.x, self.y, 40, 40)
m_rect = Rect( self.x, self.y, 40, 40 )
# 障害物を描画
fill(1, 1, 0)
for s in self.s_rect:
image('_Image_2', s.x, s.y, s.w, s.h );
# あたり判定
for i, s in enumerate( self.s_rect ):
if m_rect.intersects( s ):
'''
# あたった四角の色をかえる
fill( 1, 0, 0 )
rect( s.x, s.y, s.w, s.h )
'''
# あたった四角を消す
del self.s_rect[i]
# 音をだす
sound.play_effect('Crashing')
开发者ID:peacemaker07,项目名称:pythonista,代码行数:31,代码来源:game-sample1.py
示例6: generate_outcome
def generate_outcome():
global player_choice
computer_choice = choice(SIGNS)
v['cpu_outcome'].text = computer_choice
if player_choice == computer_choice:
play_effect('Laser_3')
v['game_result'].text = "It's a draw! Both played %s." % (player_choice)
elif player_choice == 'Paper' and computer_choice == 'Rock':
player_win('Paper', 'covers', 'rock')
elif player_choice == 'Scissors' and computer_choice == 'Paper':
player_win('Scissors', 'cut', 'paper')
elif player_choice == 'Rock' and computer_choice == 'Scissors':
player_win('Rock', 'crushes', 'scissors')
elif player_choice == 'Rock' and computer_choice == 'Paper':
player_win('Rock', 'crushes', 'paper')
elif computer_choice == 'Paper' and player_choice == 'Rock':
player_loss('Paper', 'covers', 'rock')
elif computer_choice == 'Scissors' and player_choice == 'Paper':
player_loss('Scissors', 'cut', 'paper')
elif computer_choice == 'Rock' and player_choice == 'Scissors':
player_loss('Rock', 'crushes', 'scissors')
elif computer_choice == 'Rock' and player_choice == 'Paper':
player_loss('Rock', 'crushes', 'paper')
else:
v['game_result'].text = "Whoops! This wasn\'t supposed to happen!"
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:27,代码来源:rps.py
示例7: draw
def draw(self, bright=False):
colour = self.sl if self.state else self.bg
colormod = 1 if bright else 0.8
fill(*[i*colormod for i in colour])
rect(*self.bounds)
if self.state and bright:
sound.play_effect(self.drum)
开发者ID:Vik2015,项目名称:drum-machine,代码行数:7,代码来源:drum_machine.py
示例8: losing
def losing(self):
score_value = int(self.score.text)
sound.play_effect(fail_sound)
self.green_timer_background.fill_color = color3
for square in self.squares:
if square.star:
square.star_icon.run_action(A.sequence(A.scale_to(0, 1), A.remove()))
if square.state in (0, 3):
square.state = 0
square.color = color3
try:
square.red_square.run_action(A.remove())
except:
pass
bg_target = choice(self.bg_list).position
square.run_action(A.sequence(A.wait(2),A.group(A.scale_to(0, 3), A.fade_to(0, 2), A.move_to(bg_target[0], bg_target[1], 2, TIMING_SINODIAL)), A.remove()))
self.start.color = color3
self.finish.color = color3
self.score_change(-1 * int(self.score.text), self.win)
self.score.text = "0"
self.backdrop5.color = color3
self.level_label.text = choice(fail_text)
self.move_counters()
self.destroy_crosses()
self.save(score_value)
for bg in self.bg_list:
bg.color = color3
开发者ID:cclauss,项目名称:black-white,代码行数:27,代码来源:black_white.py
示例9: panic
def panic(self, pos):
sound.play_effect("drums:Drums_06")
for b in self.swarm:
b.startled = True
s = SpriteNode("shp:wavering", position=pos, scale=0, parent=self)
s.run_action(A.sequence(A.group(A.scale_to(2), A.fade_to(0)), A.remove()))
self.run_action(A.sequence(A.wait(1), A.call(self.end_panic)))
开发者ID:miwagner1,项目名称:Pythonista,代码行数:7,代码来源:Swarm.py
示例10: die
def die(self):
self.animation_done = False
self.animate('scale_x', 0.01, repeat=2)
self.animate('scale_y', 0.01, repeat=2, completion=self.death_completion)
for i in xrange(4):
sound.play_effect('Hit_{}'.format(i+1))
time.sleep(0.5)
开发者ID:SebastianJarsve,项目名称:Cloud-Jump-2,代码行数:7,代码来源:etude_on_player_death.py
示例11: touch_pu2
def touch_pu2(self):
sound.play_effect(button_sound)
self.can_flip = False
self.stop_squares_moving()
self.level_label.text = "Restore a locked square"
if self.unlock == False:
self.unlock = True
elif self.unlock == True:
self.unlock = False
self.destroy_crosses()
self.level_label.text = "Level " + str(self.level)
return
self.powerup2.run_action(pressed_action_2)
self.powerup2_bg.run_action(pressed_action_2)
self.p2_count.run_action(pressed_action_2)
for square in self.squares:
if square.state == 0 and self.unlock and square.last_state == 1:
square.red_square = SpriteNode(texture = Texture('typb:Cross'), color = color3)
square.red_square.position = square.position
square.red_square.z_position = 0.4
self.add_child(square.red_square)
square.red_square.run_action(A.repeat(A.sequence(A.scale_to(0.85, 0.4, TIMING_EASE_IN_OUT), A.scale_to(0.95, 0.4, TIMING_EASE_IN_OUT)), 0))
elif square.state == 0 and self.unlock and square.last_state == 2:
square.red_square = SpriteNode(texture = Texture('typw:Cross'), color = color2)
square.red_square.position = square.position
square.red_square.z_position = 0.4
self.add_child(square.red_square)
square.red_square.run_action(A.repeat(A.sequence(A.scale_to(0.85, 0.4, TIMING_EASE_IN_OUT), A.scale_to(0.95, 0.4, TIMING_EASE_IN_OUT)), 0))
开发者ID:cclauss,项目名称:black-white,代码行数:31,代码来源:black_white.py
示例12: end_game
def end_game(self):
if self.score > self.highscore:
with open('.Match3Highscore', 'w') as f:
f.write(str(self.score))
self.highscore = self.score
sound.play_effect('digital:ZapTwoTone')
self.show_game_over_menu()
开发者ID:DocVaughan,项目名称:Pythonista,代码行数:7,代码来源:Match3.py
示例13: disp_end_game
def disp_end_game(self, status):
if status == 'OK':
# ゲームクリアの表示を設定
message = 'Game Clear'
color = '#00ff00'
background_color = '#ffff00'
effect = 'arcade:Powerup_1'
else:
# ゲームオーバーの表示を設定
message = 'Time Up'
color = '#ff0000'
background_color = '#000000'
effect = 'arcade:Explosion_1'
# ゲーム完了画面を表示
end_font = ('Arial Rounded MT Bold', 80)
self.end_label = LabelNode(message, end_font, parent=self)
self.end_label.position = (self.size.w/2, self.size.h - 300)
self.end_label.z_position = 1
self.end_label.color = color
self.background_color = background_color
# ゲーム終了状態にする
self.game_over = True
# ゲーム終了サウンドを鳴らす
sound.play_effect(effect)
开发者ID:peacemaker07,项目名称:pythonista,代码行数:25,代码来源:shoot2016_L07.py
示例14: tableview_did_select
def tableview_did_select(self, tableview, section, row):
# Called when the user selects a row
if not tableview.editing:
fi = self.lists[section][row]
if section == 0:
console.show_activity()
nav.push_view(make_file_list(fi))
console.hide_activity()
elif section == 1:
filetype = fi.fileinfo.filetype
if fi.fileinfo.file_ext in ("htm", "html"):
webbrowser.open("file://" + fi.path)
nav.close()
elif filetype in ("code", "code_tags", "text"):
open_path(fi.path)
nav.close()
elif filetype == "audio":
spath = rel_to_app(fi.path.rsplit(".", 1)[0])
sound.load_effect(spath)
sound.play_effect(spath)
elif filetype == "image":
console.show_image(fi.path)
else:
console.quicklook(fi.path)
nav.close()
开发者ID:Phuket2,项目名称:pythonista-scripts,代码行数:25,代码来源:filenav.py
示例15: update
def update(self, dt):
self.y -= self.speed
self.x = self.initial_x + sin(self.y / 100) * self.amp
self.amp = max(self.amp * 0.99, 0)
if self.y < -64:
self.removed = True
if self.dead:
self.a -= 0.1
if self.a <= 0:
self.removed = True
else:
self.t += 1
if not self.dead and self.t % self.fire_freq == 0:
play_effect('Laser_5')
if self.bullet_type == 1:
bullet = Bullet(self.x, self.y)
bullet.vy = -10
bullet.bullet_type = 1
self.scene.enemy_bullets.append(bullet)
elif self.bullet_type == 2:
for vx in [-3, 3]:
bullet = Bullet(self.x, self.y)
bullet.vy = -10
bullet.vx = vx
bullet.bullet_type = 2
self.scene.enemy_bullets.append(bullet)
else:
for vx in [-3, 0, 3]:
bullet = Bullet(self.x, self.y)
bullet.vy = -10
bullet.vx = vx
bullet.bullet_type = 3
self.scene.enemy_bullets.append(bullet)
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:33,代码来源:SpaceShooter.py
示例16: touch_began
def touch_began(self,touch):
if self.cc_mode == 'I':
x,y = touch.location
string = self.closest(x,self.stringX)
fret = self.closest(y,self.fretY)
location = (string,fret)
if location in self.touched.keys():
del self.touched[location]
else:
for key in self.touched.keys():
if key[0] == string:
del self.touched[key]
break
self.touched[location] = (self.tuning['notes'][string]+fret,self.tuning['octave'],string,fret)
octave,tone = divmod((self.tuning['notes'][string]+fret),12)
waveName = 'waves/' + NOTE_FILE_NAMES[tone] + "{}.wav".format(octave+self.tuning['octave'])
sound.play_effect(waveName)
self.set_needs_display()
elif self.cc_mode == 'S': # play two octave scale starting at this root
x,y = touch.location
string = self.closest(x,self.stringX)
fret = self.closest(y,self.fretY)
location = (string,fret)
octave,tone = divmod((self.tuning['notes'][string]+fret),12)
if tone != self.key:
sound.play_effect('Error')
return None
self.scaleFrets = calc_two_octave_scale(location)
self.set_needs_display()
开发者ID:zwaluw,项目名称:chordcalc,代码行数:29,代码来源:chordcalc.py
示例17: tableview_did_select
def tableview_did_select(self, tableview, section, row):
u"""Called when the user selects a row.
"""
if not tableview.editing:
fi = self.lists[section][row]
if section == 0:
console.show_activity()
self.app.push_view(self.app.make_file_list(fi))
console.hide_activity()
elif section == 1:
group = fi.constants.group
if fi.constants.ext in (u"htm", u"html"):
webbrowser.open(u"file://" + fi.path)
self.app.close()
elif group in ("code", "code_tags", "text"):
open_path(fi.path)
self.app.close()
elif group == "audio":
spath = rel_to_app(fi.path.rsplit(u".", 1)[0])
sound.load_effect(spath)
sound.play_effect(spath)
elif group == "image":
console.show_image(fi.path)
else:
self.app.close()
time.sleep(ANIM_DELAY)
console.quicklook(fi.path)
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:27,代码来源:common.py
示例18: draw
def draw(self):
background(0, 0, 0)
last_beat = int(self.beat)
self.beat += 1.0/7.5
self.beat %= 16
play = int(self.beat) != last_beat
for y in xrange(16):
beat_row = int(self.beat) == y
for x in xrange(8):
if self.grid[x][y]:
h = x / 8.0
r, g, b = hsv_to_rgb(h, 1, 1)
if play and int(self.beat) == y:
play_effect(self.sounds[x])
if beat_row:
h = x / 8.0
r, g, b = hsv_to_rgb(h, 1, 1)
fill(r, g, b)
else:
r, g, b = hsv_to_rgb(h, 1, 0.5)
fill(r, g, b)
elif beat_row:
fill(1, 1, 1)
else:
fill(0.50, 0.50, 0.50)
rect(x*(self.bounds.w/4), y*(self.bounds.h/9), self.bounds.w/4, self.bounds.h/9)
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:26,代码来源:DrumMachineEdited.py
示例19: killsoldier
def killsoldier(self) :
###kill soldier and play explosion.
play_effect(sounds[1])
self.setscore(self.count + 1)
self.explosion.start(self, self.soldier.pos)
self.shaker = 10
self.soldier.setpos(self.soldierpos)
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:7,代码来源:mines.py
示例20: touch_pu3
def touch_pu3(self):
self.unlock = False
self.stop_squares_moving()
self.level_label.text = "Flip a single square"
self.powerup3.run_action(pressed_action_2)
self.powerup3_bg.run_action(pressed_action_2)
self.p3_count.run_action(pressed_action_2)
sound.play_effect(button_sound)
if self.can_flip == False:
self.can_flip = True
elif self.can_flip == True:
self.can_flip = False
self.level_label.text = "Level " + str(self.level)
for square in self.squares:
square.remove_all_actions()
square.scale = 1
return
for item in (self.black_count, self.white_count):
item.run_action(A.repeat(A.sequence(A.scale_to(0.85, 0.4, TIMING_EASE_IN_OUT), A.scale_to(0.95, 0.4, TIMING_EASE_IN_OUT)), 0))
try:
if self.star_square:
self.star_square.star_icon.run_action(A.repeat(A.sequence(A.scale_to(0.85, 0.4, TIMING_EASE_IN_OUT), A.scale_to(0.95, 0.4, TIMING_EASE_IN_OUT)), 0))
except:
pass
for square in self.squares:
if square.state in (1, 2):
square.run_action(A.repeat(A.sequence(A.scale_to(0.85, 0.4, TIMING_EASE_IN_OUT), A.scale_to(0.95, 0.4, TIMING_EASE_IN_OUT)), 0))
开发者ID:cclauss,项目名称:black-white,代码行数:27,代码来源:black_white.py
注:本文中的sound.play_effect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论