Class BuiltinSounds

java.lang.Object
org.openpatch.scratch.internal.BuiltinSounds

public final class BuiltinSounds extends Object
Registry for the sound effects that ship inside the Scratch for Java jar.

The bundled sounds come from kenney.nl and are released under CC0, so they can be used for any purpose without attribution. They can be addressed by plain name:


 sprite.addSound("footstep_carpet_000");
 

Every bundled sound has a unique name, so no folder has to be given. Lookup ignores case.

  • Method Details

    • get

      public static String get(String name)
      Looks up a bundled sound.
      Parameters:
      name - the name of a bundled sound, without folder or extension
      Returns:
      the resource path to hand to the sound loader, or null if unknown
    • contains

      public static boolean contains(String name)
      Checks whether a bundled sound with this name exists.
      Parameters:
      name - the name to look for
      Returns:
      true if it exists
    • getNames

      public static List<String> getNames()
      Returns every bundled sound name.
      Returns:
      all available names
    • suggest

      public static List<String> suggest(String name, int limit)
      Finds bundled sound names close to what was typed, so a wrong name can be answered with "did you mean ...?".
      Parameters:
      name - the name that could not be found
      limit - how many suggestions to return at most
      Returns:
      the closest matching names, best first