How do I make a sound not loop but repeat

0 favourites
  • 13 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Hi so I want to make a sound pop up when a layer comes visible.

    This is somewhat something like a tutorial or explanation. If you pick X or Y or whatever, a layer becomes visible where a character with a text box comes and explain you the mechanic/item/whatever.

    I want to to add a sound for when this happens so I figured I would add a sound whenever that layer becomes visible. The problem is if I dont set trigger once while true, the audio loops as long as stays visible and if I trigger it, works fine but only happens the first time the layer becomes visible and I want it to happen everytime.

    Long story short: I want a sound to pop up when a layer becomes visible, just play ONCE at the start, do not repeat as long as is visible and I want it to happen every time the layer becomes visible.

    Any ideas?

  • You need an instance variable. Set it to boolean. Toggle it from false to true when the layer is visible and back to false when invisble. Make it that the sound only plays when said variable is false. That should make the "trigger once while true" obsolete.

  • I'm not sure how to do what you're saying. I've set up this:

    If layer X is visible set to true

    If layer X is not visible set to false.

    I can't seem to find any condition to run if boolean is A do B. The system variables are only available for globals not instance. Sorry if I make stupid questions but I lack a lot of knowledge.

  • Anyone? Please

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, here we go. This should do the trick:

    The player object gets the boolean "hintVisible". Set it to false. The layer "hint" is only visible when this boolean is true. It is toggled by hitting the blue collision object. Then a counter with a global variable starts. After 6 seconds (adjust it to your needs) the boolean is toggled to false, the layer becomes invisible and the player can hit the collision object again repeating the procedure. Since "on collision with object" is identical to "trigger once while true" the sound is played once when toggeling the boolean.

  • That doesn't work for my case. I do not want any countdown and I need to set it as a layer is visible not as an object with collision. That's exactly the problem.

  • [quote:1nnl604y]Hi so I want to make a sound pop up when a layer comes visible.

    That was your problem. My setup solved this problem. Have you at least tried it out?

    The layer "hint" becomes visible when hitting the collision object - a sound is played once. You can replace the condition on collision with object with what ever you want. The counter is just for making the layer invisible again so the procedure can be repeated. You can also replace this mechanic with whatever you want.

  • Hello liquidmetal. I tried it and didn't work out for the kinda of effect I was looking for. Somehow I managed to pull it off in other way that suits me better.

    Thank you very much for your kind help, is been helpfull regardless

  • I'm having a similar situation

  • couldnt you just trigger the audio in the same place you're displaying the layer?

    • when something happens

    - display layer

    - trigger audio once

    ...?

    edit: like liquidmetal's solution haha

  • I think we found an acceptable solution to this situation, see this link where the file .capx project.

    http : // bit. ly/ hidePlaysound

    => How was the application logic

    *

    *

    => How was the layout

    *

    *

    => The configuration of the layers thereof.

    *

    *

  • See above in this example resolve your case.

  • Take a look at the tutorial I made:

    https://www.scirra.com/tutorials/4809/h ... thout-loop

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