Store sound effects in an array and play it

0 favourites
  • 1 posts
From the Asset Store
A set of board games to make your day joyful. Play, Enjoy, Relax
  • 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();

    });

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)