Store sound effects in an array and play it

Get help using Construct 2

Post » Fri Feb 07, 2014 8:45 am

Hi, I'm new to C2, and apologize if this is a noob question. I have a series of sounds effects, and I would like to play a particular sound effect when a magic wand of particular color (sprite) is dragged onto another sprite. The magic wand sprite has an instance variable of type int that indicates which color it is, and I was wondering if it is possible to save the sound effects in an array object, then depending on which instance variable of the magic wand, play a particular sound effect?

For instance, if I were to do this in javascript, the code would look something like below. Is there any easy way to replicate this in C2?

var arrSounds = ['1.ogg', '2.ogg', '3.ogg'];
objToDetectDrop.addEventListener('dragover' function(e) {
    //blah blah blah
    arrSounds[e.dataTransfer.getData('color')].play();
});
B
3
Posts: 5
Reputation: 235

Return to How do I....?

Who is online

Users browsing this forum: Allardje, Rudi55, sublimate, Yahoo [Bot] and 3 guests