(solved)choose a frame between 2 different ranges

0 favourites
  • 6 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • per korbaach

    solution is:


    The original question was:

    So I know how to ::

    choose(0,1,2,3,4,5,6,7,8) to select a certain frame number

    and I know how to

    int(random(0,39)) to randomly select a whole number between 0 and 38.

    but what if I wanted to

    randomly select a frame number between 2 different ranges?

    for example:

    I have 40 frames, and I want to NOT select one of them;

    for example frame 20

    I could do


    but this seems pretty long and time consuming if I had multiple events doing the same thing with a different number, so I was hoping that there was a way to

    do something like this:



    but these don't work.

    Anyone know a solution?

    is there one?




    per korbaach

    solution is:


  • Try Construct 3

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

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


  • I think this might be some work-around in general idea:

    [pseudo code]

    randomNumber1 = random(1..19)

    randomNumber2 = random(21..39)

    pickNumber = random(1,2)

    if pickNumber == 1

    return randomNumber1

    else return randomNumber2

    ---- or a bit prettier way ----

    pickRange = random(1,2)

    if pickRange == 1

    return random(1..19)

    else return random(21..39)

  • korbaach

    Thanks for the answer.

    correct me if I am wrong but I think you meant


    just so people visiting this topic don't get confused

  • thanks for answering

  • oh,

    Just a quick reminder to those looking at this forum post ( cause I actually forgot after I tried to test the code)....

    Per the manual:

    Random(N) - Returns a random number between 0 and N, not including N

    so in the above example,

    to exclude frame 20

    the code would actually need to be


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