Building Android Apps in Python Using Kivy with Android Studio by Ahmed Fawzy Mohamed Gad

Building Android Apps in Python Using Kivy with Android Studio by Ahmed Fawzy Mohamed Gad

Author:Ahmed Fawzy Mohamed Gad
Language: eng
Format: epub
ISBN: 9781484250310
Publisher: Apress


if len(coins_to_delete) > 0:

for coin_key in coins_to_delete:

del TestApp.coins_ids[coin_key]

app = TestApp()

app.run()

Listing 5-43Updating the Label Displaying the Number of Collected Coins and Displaying a Message When the Level Completes

Figure 5-27 shows the result after the level is completed.

Figure 5-27A message is displayed when the level completes

Sound Effects

A game without sound effects is not a very good game. Sound is an important factor of the user experience. You can add sound effects to every action happening in the game. For our game, we will add sound effects to the character’s death, when completing a level, and when collecting coins. This is in addition to the background music, which helps the players engage with the game.

Kivy provides a very simple interface for playing sounds using the SoundLoader class found in the kivy.core.audio module. The modified Python file in which sounds are loaded and played is shown in Listing 5-44.import kivy.app

import kivy.animation

import kivy.uix.image

import kivy.uix.label

import random

import kivy.core.audio

import os



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.