How do use an returned Array in the event sheet?

0 favourites
  • 2 posts
From the Asset Store
Bring the Wild West to life with this Cowgirl Sprite Sheet!.
  • My Javascript function changes hex values to rgb like so:

    localVars.gotColour = hexToRgb("#bceadf");
    

    The function is returning an object which contains rgb values like so.

    return {r, g, b};
    

    But how do I get theses into the event sheet as something useable? The gotColour variable is an object with the 3 variables inside, but I cant seem to use it for anything useful. (apart from printing object r:12, g:34 b:34 to the console)

    I would have expected I could do something like the following in the event sheet after the function had been run:

    Set Colour to gotColour //does nothing

    .or this..

    Set Colour to rgbEx255(gotColour[0],gotColour[1],gotColour[2]) //bad syntax

    ..but those do nothing....

    I guess I could write 3 different functions to each get the r,g,b values individually but that seems very messy.

    Any tips?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The colors that construct support are just one single number. That js library appears to return an objects so I guess you'd get the color with rgbEx255(gotColour.r,gotColour.g,gotColour.b) but I'm almost certain that rgb function is accessed differently in js than in events.

    If you want a event based solution there's this:

    construct.net/en/forum/construct-3/how-do-i-8/hex-colour-values-code-179603

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