if then else issue [image attached]

0 favourites
  • The sound is not playing

    NONE of the sound is playing.

    What did I do wrong ?

    I know for a fact that this function is being called.

  • Why do you use only one event for all RandomNumber condition ?

    use one event for one condition

  • I don't understand what you mean anata, I only want to check the value of RandomNumber once to see if they match any of this value after the function PlayRandomScrollingSound() has done manipulating the number.

    In any other programming language it would be a simple:

    Switch Case [C++]

    or Select Case in Visual Basic.

    Example:

    switch (floor(random(8)))
    {
    case 0:
    PlaySound0;
    break;
    
    case 1:
    PlaySound1;
    break;
    
    case 2:
    PlaySound2;
    break;
    }
    [/code:13ibppam]
    Why is the simplest thing so difficult in this drag and drop paradigm ?
  • Event 12 is an AND! Separate them into separate events/actions.

  • Oh I understand what you mean now anata, will updated corrected pic if anyone wants to learn in a while.

  • same as this ^^

  • This is the correct image.

    Thanks to anata

  • You could place the Stop under the Set RandomNumber action, so it doesn't need to be repeated 8 times.

  • [attachment=1:20be9h6c][/attachment:20be9h6c]

    Just another way to do it.

  • Thanks blackhornet for the tip

    DUTOIT, you are awesome thanks !

  • And another:

    RandomScrollingSound0

    RandomScrollingSound1

    RandomScrollingSound2

    RandomScrollingSound3

    If foo audio object "Play by name" RandomScrollingSound&int(random(3))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • DUTOIT, you just turn my long list of conditions into one.

    You

    ARE

    AWESOME !

    I saw your tip newt, but that would require me to rename the files ;p

  • DUTOIT, you just turn my long list of conditions into one.

    You

    ARE

    AWESOME !

    Just a minimalist at heart and having experienced similar problem when I tried to shave off 1000 events and checks from entire project.

    Glad you found it helpful.

    newt,

    N1, even simpler - lol

  • And another:

    RandomScrollingSound0

    RandomScrollingSound1

    RandomScrollingSound2

    RandomScrollingSound3

    If foo audio object "Play by name" RandomScrollingSound&int(random(3))

    newt, can you please confirm, will the "int" pick the last sound (3), doesn't "int" rounds down the numbers? I thought that we had to use "round" on these cases, because round is picking the upper values when the number is e.g 2.6, it will choose 3.

  • Nah, random, like everything else in C2 is zero based, meaning it starts at zero rather than 1.

    Remember 0 is still an integer, it just has no value.

    int(random(4)) would have included all 4 sounds.

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