How do I add an audio to an object

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Firstly, I want to add a fire burning sound at the Fire object, which I wanted that when the Fire is far away, the sound gets softer and when the Fire is near, the sound gets louder.

    However, I tried using

    "On start layout" then I select "Play at object", i choose the fire burning sound and select Fire as the object.

    And the problem is, the fire burning sound does not get softer nor louder even the distance has changed. Any idea?

  • I haven't played with this kind of thing yet, but I have looked into the Audio a decent amount. Have you considered tying the playing of the sound to the distance Object B is from Fire? So as Object B gets closer to Fire, Fire's Audio event kicks in at a certain volume level; as Object B gets further away, Fire's Audio event kicks in at a lower volume level.

    Would that help?

  • You need to configure your Audio object correctly, as seen in this example.

    [attachment=0:3dp8ging][/attachment:3dp8ging]

  • GeometriX Now I know what's the problem I have, I didn't put the audio action as "Set listener object", thanks a lot!

  • I need help again, the audio loudness affected by distance works ok when I tested in computer(I used chrome browser), but when I test my game on my phone, the audio loudness does not change even the Player is near or far from the Fire object. Anyone can help me, thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • From manual:

    "Advanced audio

    The Audio object supports some advanced features, such as positioned sounds and convolution effects. However these depend on the Web Audio API which is not supported in all browsers. You can detect if these features are available using the Advanced audio supported condition. If it is not supported, the advanced audio features will not change the sound in any way.

    Positioned sounds are an advanced audio feature that allow you to play a sound at a position, or on an object, in the layout. Using a 3D audio engine, the pan and volume are adjusted according to their relative position to the listener. This is an easy way to enhance realism and further immerse the player in the game."

    Probably the phone doesn't support advanced audio.

  • so is there anyway that I can use alternative way to make the same feature(advanced audio position), maybe in construct 2 i put the event in another specific way?

  • You can try comparing the player distance to the fire and choose how close they have to be to start hearing the fire. Then adjust it depending on the closeness.

  • PhoenixNightly ya I also thought of that, but I'm a beginner and I not sure how to do it.

  • serge Low

    Once I finish some school reports I have to write up I will help you out.

  • ok thanks a lot

  • First view this to see what the results would be-https://dl.dropboxusercontent.com/u/128026415/SoundTest/index.html

    Move with the arrow keys

    **Note disregard the toggle button doesn't function***

    WHAT IS HAPPENING?

    What I did was setup a soundRange that follows the player where ever they go and each level triggers the sound for that object. Green for low level sound Yellow for Mid level sound and Red for full sound. (Which you can see in the top image below)

    IMPLEMENTATION

    Now for the soundLevels I set a instance variable called soundRange to tell what level to play the sound at. for the object 'Fire' it has two variable instance 'soundFile'-for the audio file that needs to be played and 'inRange'-which is triggered when they enter the Green Zone. When object exits it zeros it out and stops the tagged sound.

    I did it this way cause I notice from your profile you don't have a license. So look at how my events is setup below and try to implement it yourself. Also I did test it on my android in Cocoonjs and it did work for me.

    But if you have more items for sound depending on range a license would be beneficial because you can use Families. Which is nice cause you can declare the instance variable in that and it would be transferred to whatever objects is in the family and you can set each object as you please.

    With Families it would look like this::

    So any object in soundItems would be tested.

    **UPDATE**Just pin each range to the playerSprite is better.

  • Updated the events a little more. This uses 'Families' so I don't have to setup the same event for each object that has sound. Also make it that when a object triggers the sound to make it so that another object that may have the same file to make each object sound tag unique I used their UID in the naming of the sound.

    You can see the changes here-http://bit.ly/1fOoXrp

    Use the arrow keys to move the purple box.

    ::SCENE LAYOUT::

    ::EVENT CHANGES::

    If you don't have a license for every object that you wanted to do something like this you would have to set up the event individually or use frames...but then code each soundfile for each frame. Which does become unreadable to an extent and make a higher possibility of errors.

  • wow you're great man, I'll will have to take some time to look at this! ^^

    btw, just wanna ask a different topic things, how to add ads into my game without going using eclipse or other advanced programming tools? And I've searched a lot in google about MoPub and AdMob, it requires me to add MoPub SDK into eclipse and bla bla bla all the coding, so I just wanna ask is there an easier way to set up ads into my mobile game? Best is it doesn't require money

  • Can't answer that at the moment cause I haven't done it. but I am planning to package something soon and have been trying to see if I can integrate Amazon or Chartboost which would probably require me to go through eclipse to do.

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