Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I just bought CopperCube and using it with CopperLicht in the hopes of creating some "educational" games for my boys. I see how to add sounds via CopperCube but would like to manipulate/play/stop those sounds in JavaScript. I have not been able to find any examples...Does anyone have some examples of how you can start and stop sounds that have already been added to the scene via the CopperCube publish to WebGL? I look forward to really having fun with this engine (and hopefully my boys will too)! Thanks |
||||
|
Well I poked around in CopperLicht and this seems to work: var sound = scene.getSceneNodeFromName("Explosion"); var soundMgr = CL3D.gSoundManager; soundMgr.play2D(this.sound.TheSound); W |
||||
|
Didn't get a chance to finish my last post... Where "Explosion" is a Sound Node previously created in CopperCube. How would you handle 3D sound? Thanks |
||||
|
Unfortunately, the HTML 5 audio API doesn't allow real 3d sound yet, so currently, it's only a volume change. For 3D sound, you could create the (undocumented) soundSceneNode. Something like this should work (I haven't tried it out)
|
||||
|
niko, Hey thanks! I think we're all very hopeful concerning HTML 5. However, this looks like it'll work for my purposes. I'll try it out and let you know... Thanks again |
||||
|
Hmmm, I’m not sure I’m dealing with it correctly but this is what I observed: I’m not sensing any variability in volume based upon the position of the Sound Node with respect to the active camera position (i.e. player). However, the MaxDistance does significantly affect the volume level – the shorter distance the louder the volume. I assumed the MaxDistance would affect how far away the “player” would be able to detect the sound (i.e. drops off when player is > MaxDistance away from the sound while < MaxDistance the vol is interpolated based upon delta between active camera position and Sound Node position). Does the volume automatically adjust based upon active camera position with respect to sound node position or are my assumptions out in “left field”? Thanks |
||||
|
Hm, it works nearly the same way as if you would create the sound node in the editor CopperCube, and there it works, try it out. What could be is that you chose a too big value for Min and Max, try much smaller ones. (for example set both to 20). The fallof is not linear but logarithmic. |
||||
|
How do you stop a sound from playing? I have tried: soundMgr.stop( s.TheSound ); and I get an error. Thanks |
||||
|
Hm, did you try soundMgr.stop(s) instead? |
||||
|
I tried that ,and still get the same error. Uncaught TypeError: Cannot read property 'audioElm' of undefinede |
||||
|
I've now looked into it: that's a bug. Will be fixed in the next update. For now, you can stop sound using this code:
|
||||
|
I tried that, but I still get the same error. |
|