Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Automatically Add Sound Sprites via loadBundle #272

Open
furic opened this issue Oct 2, 2024 · 0 comments
Open

Feature: Automatically Add Sound Sprites via loadBundle #272

furic opened this issue Oct 2, 2024 · 0 comments

Comments

@furic
Copy link

furic commented Oct 2, 2024

It would be great if Assets.loadBundle() in Pixi could automatically handle sound spritesheets, making asset management even more efficient. I’ve submitted a related feature request in Pixi’s Asset Pack to support packing sounds into a sound spritesheet.

The idea is for Pixi to recognize a sound spritesheet in the bundle assets and automatically add the sound sprites based on the provided sounds.json file.

Here’s an example of how this could work:

// Init the manifest
 await Assets.init({
     manifest: {
         bundles: [
             {
                 name: 'load-screen',
                 assets: [
                     {
                         name: 'sounds',
                         srcs: 'sounds.json'
                     },
                 ],
             },
             ...
         ],
     },
 });
 
 // Load the bundle
const loadingScreenAssets = await PIXI.Assets.loadBundle('loading-screen');

// Create a new sound
const sound = PIXI.sound.Sound.from(loadingScreenAssets.sounds);

// Pixi should automatically recognize the sound spritesheet and add all sprites
// No need for explicit sound.addSprites({...})

// Use the sprite alias to play
sound.play('bgm_main');

Here’s a sample sounds.json file:

{
    "sprites": {
        "bgm_main": [0, 10, true], /* true for looping */
        ...
    },
    "srcs": {
        "./sounds.ogg",
        "./sounds.mp3",
    }
}

This feature would streamline the process by eliminating the need to manually call sound.addSprites({...}), allowing for more seamless sound management in Pixi.

@furic furic changed the title Feature Request: Automatically Add Sound Sprites via loadBundle Feature: Automatically Add Sound Sprites via loadBundle Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant