Skip to content

Commit 20b26c8

Browse files
committed
Fix sprite bullets aimed example does not play sounds
1 parent f9eb15e commit 20b26c8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arcade/examples/sprite_bullets_aimed.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def on_draw(self):
109109
def on_mouse_press(self, x, y, button, modifiers):
110110
""" Called whenever the mouse button is clicked. """
111111

112+
# Play the gun sound
113+
self.gun_sound.play()
114+
112115
# Create a bullet
113116
bullet = arcade.Sprite(
114117
":resources:images/space_shooter/laserBlue01.png",
@@ -159,10 +162,12 @@ def on_update(self, delta_time):
159162
# Check this bullet to see if it hit a coin
160163
hit_list = arcade.check_for_collision_with_list(bullet, self.coin_list)
161164

162-
# If it did, get rid of the bullet
165+
# If it did, get rid of the bullet and play the hit sound
163166
if len(hit_list) > 0:
164167
bullet.remove_from_sprite_lists()
165168

169+
self.hit_sound.play()
170+
166171
# For every coin we hit, add to the score and remove the coin
167172
for coin in hit_list:
168173
coin.remove_from_sprite_lists()

0 commit comments

Comments
 (0)