How do I play a sound depending on which object is selected?

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi.

    First off, I'm a real beginner. I've read through a bunch of tutorials and articles and I've been playing around with the 'Creating a Memory Match Game' tutorial which was really great for learning but I'm getting stuck when trying to link objects with sound.

    I'm trying to build a sound matching game for kids, where they get shown a collection of animals, a sound gets played and they have to click on the right animal. Each animal has a static image and a sound file. I've got it so that the game picks a random 4 animals from the collection and it picks a random one of these as the correct one, but then how do I play the correct sound file, without having an event for each animal?

    I'm fine with basic audio, playing a sound as an action assigned to an event, but I can't work out how to do it conditionally, i.e. if the cow image is selected, then play the cow sound. It feels like it's a really simple thing to do but I'm just missing some basic bit of knowledge to get it working. If anyone can help me it'd be greatly appreciated.

    Thanks,

    James

  • well that's super easy Distinction ,

    basically lets say you have 12 animal pictures, right? now for the condition of the image selected so audio can play you have to do the on touch of if you want more advanced things you can do with booleans and trigger them as selected or stuff like that but for starters, the easy way now is

    On touched object (cow) --------------------(/ or you can use tap also)

    Audio>

    > play sound cow no repeat

    > tag"cow"

    and so on for all the images

    if you can add a capx i could help you out and fix it for you if you want and don't have disclosure problems

  • ..or use Array to store audio file names..and only one Sprite for animals..

    capx> http://s000.tinyupload.com/index.php?fi ... 2654540641

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • or

    see this tut. maybe it will help

    https://www.scirra.com/tutorials/1441/p ... ext-object

  • Cheers all, I found the tutorial that korbaach's example must have been based on and managed to get it working using arrays. Thanks for your help

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)