Set Instances of Canvas Object to Different Colors

Get help using Construct 2

Post » Sun Jan 05, 2014 10:32 pm

I am using the canvas plugin to create a canvas box of which I have several instances. I am trying to give each one a random rgb color. So far I have been successful in setting three instance vars on each object I have created to be a random r,g,b value. But when I try to set the fill color on each instance, it does not work. All the instances are getting set to the color of the main object.

"rgb("&Canvas(NUMBER_OF_TILES_X_MADE).r&",
"&Canvas(NUMBER_OF_TILES_X_MADE).g&",
"&Canvas(NUMBER_OF_TILES_X_MADE).b&")"

NUMBER_OF_TILES_X_MADE increments.


image : imgur/uC0RHXrh455492014-01-05 22:33:41
B
3
Posts: 5
Reputation: 185

Post » Sun Jan 05, 2014 10:49 pm

One interesting thing I am noticing is that following works and sets all colors to red,

"rgb("&100&","&0&","&0&")"

but

"rgb("&100&","&random(255)&","&0&")"

fails and all instances turn black
B
3
Posts: 5
Reputation: 185

Post » Sun Jan 05, 2014 11:03 pm

I have figuered out the issue was trying to pass a fraction to rgb(), applying ceil fixed it.
B
3
Posts: 5
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: mihirolover, Prominent, tarek2 and 12 guests