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

Get help using Construct 2

Post » Sat Jul 25, 2015 9:47 am

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:
Image

Image

EDIT: almost forgot, I also want to save the UID of the picked object to the "Array". thanks again!
B
3
Posts: 8
Reputation: 195

Post » Sat Jul 25, 2015 12:14 pm

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.
B
8
S
1
Posts: 76
Reputation: 628

Post » Sat Jul 25, 2015 1:37 pm

If you want a total 4.5 second flash you can use like this
Image
https://drive.google.com/file/d/0BzXd1GMzUo9HVzhwR0pJSEw1dnc/view?usp=sharing
B
21
S
8
G
6
Posts: 177
Reputation: 8,134

Post » Sat Jul 25, 2015 5:25 pm

yapiiiii wrote: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 :D
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 :)
B
3
Posts: 8
Reputation: 195

Post » Sat Jul 25, 2015 5:26 pm

note: I also added a "Wait 1.5 seconds" at the end of the actions, no luck.
B
3
Posts: 8
Reputation: 195

Post » Sat Jul 25, 2015 6:09 pm

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
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sat Jul 25, 2015 6:31 pm

R0J0hound wrote: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 :)
B
3
Posts: 8
Reputation: 195

Post » Fri Dec 25, 2015 6:08 am

@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
B
3
Posts: 2
Reputation: 179

Post » Tue Dec 29, 2015 5:08 am

Message: conan is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
mrcgkh wrote:If you want a total 4.5 second flash you can use like this
Image


its working, thank you
but it stops after flashing all the six blocks
how to make it continuously flash,without stopping?
please reply
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: rayolf and 18 guests