How do I set a random number to an instance

Get help using Construct 2

Post » Sun Jun 01, 2014 11:22 pm

What I'm trying to do here is more than the title suggests. I want to, at the start of the layout, give 16 instances of an object different integers ranging between 0 and 15 so I can change their colour accordingly (This means every instance of the object will have a different colour). What I have so far is this (capx):
Image

However, when I run my game, the layout which this is for will not load. If I remove the flooring of the random it will, but then the colours generated can be too similar. How can this be achieved?
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Sun Jun 01, 2014 11:51 pm

You are probably misusing the loop but I don't know where the problem is.

The random color by it self is easy however. You could also use the random values with an instance variable to store the color for each instance.
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon Jun 02, 2014 12:11 am

This isn't what I'm looking for though. Your example shows just picking random colours. The colours I'm needing cannot be the same and they must have the correct hue values (Hue's can be 0/15, 100/15, 200/15, 300/15 etc).
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Mon Jun 02, 2014 12:20 am

I see. Then yes, you need some kind of a loop that checks if one color is the same with an other and if yes to change it. I'll be damned if I knew how it's done 8\

Sorry for not being able to help, I am sure that others can though ;)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon Jun 02, 2014 12:53 am

My graphics card locks up with that effect so I can't open the capx, but an event like this should work well to make each ColorBox have a different color.

For each ColorBox ordered by random(1)
---Set effect "AdjustHSL" parameter 0 to loopindex*100/15
B
94
S
33
G
114
Posts: 5,362
Reputation: 73,785

Post » Tue Jun 03, 2014 4:25 pm

Thanks :) This works perfectly :D
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests