Kree Documentation
  • Welcome to Kree Java
  • Changelog
  • Getting Started
    • Installing Kree
    • Installing Kree using CLI
    • Get Help on Discord
  • Core Components
    • Game
    • Window
    • SceneManager
    • Input
    • Debug
    • Sprite
    • GameObject
    • Transform
    • Vector2
    • SpriteSheet
    • Animation
    • Audio
    • Random
  • GameObject components
    • Animator
    • BoxCollider
    • LookAtObject
    • Mesh Renderer
    • ParticleSystem
    • RigidBody
    • SpriteRenderer
    • PlayerMovement
    • Prefs
  • Kree User Interface
    • Text
    • TextInput
    • ProgressBar
    • Button
    • Panel
  • Code Snippets
    • Launcher
    • Creating Scene
    • Follow Mouse On Click
    • Animating GameObject
    • Implementing Particle System
    • Creating Custom Components
    • Playing Audio
  • Game Tutorials
  • Avoid the Enemy!
  • High score
Powered by GitBook
On this page

Was this helpful?

  1. Code Snippets

Playing Audio

File names may vary depending on your assets.

public class SceneNameHere extends Scene {

    private Audio audioOnClick = new Audio("Assets/myAudio.wav");

    public SceneNameHere(Game game) {
        super(game);

    }

    @Override
    public void Initialize() {



    }

    @Override
    public void Update() {

        if(Input.mouseClicked) {
            if(!audioOnClick.isPlaying()) {
                audioOnClick.play();
            }
        }

    }

    @Override
    public void Render(Graphics g) {


    }


}
PreviousCreating Custom ComponentsNextAvoid the Enemy!

Last updated 5 years ago

Was this helpful?