Like sprite, we just let user create sprite with image and don’t have to deal with texture id, maybe we should do the same here, It’s much easier to manage.
how to play multiple sound, it’s up to developer to decide how they want to use that.
auto img = sprite::create("image.png");
addChild(img);
auto sound1 = sound::create("sound1.mp3");
sound1->play();
auto sound2 = sound::create("sound2.mp3");
sound2->play();
// I want to stop sound1 and play sound1 from the start again
sound1->play();
Compare to
int sound1 = audio::play2d("sound1.mp3");
audio::stop(sound1);
int sound2 = audio::play2d("sound2.mp3");
audio::stop(sound2);
//I want to start sound1 and play sound1 from the start again
audio::stop(sound1);
sound1 = audio::play2d("sound1.mp3");
In fact libGDX, flash, Unity, you can all create sound and use something like sound->play()
http://answers.unity3d.com/questions/12546/playing-audio-clip.html
http://www.gamefromscratch.com/post/2013/11/19/LibGDX-Tutorial-8-Audio.aspx
long id = mp3Sound.loop(); Timer.schedule(new Task(){ @Override public void run(){ mp3Sound.stop(id); } }, 5.0f);
long id = wavSound.play();
wavSound.setPitch(id,0.5f);
--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sound wavSound = Gdx.audio.newSound(Gdx.files.internal("data/wav.wav")); Sound oggSound = Gdx.audio.newSound(Gdx.files.internal("data/ogg.ogg")); Sound mp3Sound = Gdx.audio.newSound(Gdx.files.internal("data/mp3.mp3"));