How do I make random instances of an object flash one by one

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi all,

    I'm getting a little confused here; I have 6 instances of an object (named "BlockNumber"). I want to make three of them flash randomly each 1.5 seconds. (three objects are picked randomly) I wrote this code in the events section but it makes those three flash all together at the same time. I'm a beginner in construct 2 and I have no idea what I'm doing wrong

    Thank you in advance

    Here is the code:

    EDIT: almost forgot, I also want to save the UID of the picked object to the "Array". thanks again!

  • Actually, I think your code is correct (however, i don't understand the "add 1 to index" action)

    You just have to change the flash values: write "random(0.1,0.3)" instead of "0.2" in the flash parameters.

    The sprites will flash at random speeds.

  • If you want a total 4.5 second flash you can use like this

    https://drive.google.com/file/d/0BzXd1GMzUo9HVzhwR0pJSEw1dnc/view?usp=sharing

  • Actually, I think your code is correct (however, i don't understand the "add 1 to index" action)

    You just have to change the flash values: write "random(0.1,0.3)" instead of "0.2" in the flash parameters.

    The sprites will flash at random speeds.

    I think I kind of confused you too with my question

    What I meant was that I'm trying to make them flash one at a time, for example:

    block(1) -> flashes [block(1) is randomly picked]

    then wait 1.5 seconds

    then block(2) -> flashes [block(2) is also randomly picked]

    then again wait 1.5 seconds

    then block(3) -> flashes [block(3) is again randomly picked]

    in the meantime as each of the blocks are picked I want to add their UID to the array (that's what the "index" is there for!, each time it adds the UID to array it increases the index of the array by 1)

    as I said I'm a beginner at this so please let me know if I misunderstood any of these.

    Thanks

  • note: I also added a "Wait 1.5 seconds" at the end of the actions, no luck.

  • This could do it.

    Start of layout

    For each block ordered by random(1) ascending

    System compare: loopindex<3

    --- wait 1.5*loopindex

    --- array set at loopindex to block.uid

    --- block flash for 1.5 seconds

  • This could do it.

    Start of layout

    For each block ordered by random(1) ascending

    System compare: loopindex<3

    --- wait 1.5*loopindex

    --- array set at loopindex to block.uid

    --- block flash for 1.5 seconds

    Awesome! it worked! thank you!

    something weird happened at first though; when I wrote your code and ran it, all the blocks were flashing quickly and funny, I closed construct 2 and reopened it and it worked!

    Thank you everyone for your answers

  • mrcgkh

    excellent!! it worked.

    but I want that flashing to repeat.

    the program makes 6 blocks to flash one by one.

    when all blocks are finished flashing,it stops.

    but it should continuously flash, how to do that? please help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want a total 4.5 second flash you can use like this

    its working, thank you

    but it stops after flashing all the six blocks

    how to make it continuously flash,without stopping?

    please reply

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