Skip to content

Sound Clips

Millie Macdonald edited this page Jan 18, 2017 · 1 revision

Sounds Clips

Sounds clips (SFX or background music) can be played anywhere in the game using GameManager.

Method Params Returns Description
playClip String resource none static method
Plays the audio clip in the clip cache from the resource, the clip cache will attempt to load a new audio clip from the resource if it wasn't found.
Resource is the sound file name including extension where the sound file is located inside "resources/sounds"
playBackgroundMusic String resource none static method
Plays the audio clip on an infinite loop in the clip cache from the resource, the clip cache will attempt to load a new audio clip from the resource if it wasn't found.
Resource is the sound file name including extension where the sound file is located inside "resources/sounds"
stopBackgroundMusic none none static method
stops the background music currently playing

Clip Cache

The clip cache loads AudioClips into a hashmap with their filename. This is so that multiple AudioClips of the same resource are not loaded at the same time wasting memory and it also handles errors in loading invalid resources.

ClipCache is static so there is no constructor method to use.

Method Parameters Returns Description
getClip String resource AudioClip Attempts to get the AudioClip in the cache linked to the given resources, if not found it then attempts to load a new AudioClip from the given resource, add it to the cache and return it, if loading the resource fails then the cache is unchanged and null is returned.

Home

Saving and Loading

Statistics tracking

Game Play

APIs


Game Guide

Other Guides

Design Guides

Overviews

Features

Animations

Splash Screen & Create Account Screen

Player Account Settings

AI

Duck Dust


Brainstorming


Future Development


http://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gif

Clone this wiki locally