Set Instances of Canvas Object to Different Colors

0 favourites
  • 3 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • 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/uC0RHXr

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have figuered out the issue was trying to pass a fraction to rgb(), applying ceil fixed it.

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