Tutorial4 and sound problems

3 views
Skip to first unread message

skipper

unread,
Apr 4, 2011, 5:31:40 AM4/4/11
to The Render Engine
Hey gang.

I just started playing with RenderEngine for a game idea I wanted to
try out. I was working through the tutorials and ran into a problem
with sound on Tutorial 4 (the one with the piano keys).

I'm running on Mac OS X, using MAMP (apache web server) to serve the
pages.

The animations work fine. However when it gets to the :

onKeyDown: function(charCode) {
// These will trigger a dot on the key being played
if (charCode >= 49 && charCode <= 56) {
this.sounds[charCode - 49].play();
this.dots[charCode - 49] = true;

}
return false;
},

this.sounds[] is full of NULL values. So somehow the previous:

this.sounds.push(Tutorial4.soundLoader.get("c1"));

is returning NULL for those values. Any ideas why? the resource
paths look correct and we are loading the resources/fingerboard.png
via the image loader correctly.

Thanks,

Skipper

skipper

unread,
Apr 6, 2011, 10:30:33 PM4/6/11
to The Render Engine
Update:

I have noticed that I can play the sounds in the onKeyDown event by
accessing the soundLoader directly:

onKeyDown: function(charCode) {
// These will trigger a dot on the key being played
if (charCode >= 49 && charCode <= 56) {

Tutorial4.soundLoader.get("c1").play({volume:15} );
// this.sounds[charCode - 49].play();
this.dots[charCode - 49] = true;

}
return false;
}

So, I'm beginning to think that the soundLoader.isReady() method is
returning true before the sounds are actually loaded:

if (Tutorial4.imageLoader.isReady() &&
Tutorial4.soundLoader.isReady()) {
this.destroy();
Tutorial4.run();
return;
}

and maybe that is why the array is unable to retrieve any sounds and
only contains null values.
Reply all
Reply to author
Forward
0 new messages