Shifting/Blending Colors

RacetotheMoonRacetotheMoon Member Posts: 323
I'm looking to allow an actor to change from one specified color to another. However, rather than having it immediately snap to the specified RGB value, I'd instead like the color, over the course of 1-2 seconds, to shift, or blend, to the next.

ie. RGB value (0,.25,.38) --> RGB value (0,.65, 0)

I'm assuming this needs to be done with an equation of some kind to translate each RGB value but my familiarity with coding is so minimal I'm not sure if I'm even looking in the right direction. I've been scouring the board and shared projects to see if there was anything similar, CodeMonkey's BodyShop (Demo) has helped get me pretty far. I'm afraid the more I look at stuff the more confused, and off topic, I'm getting.

If anyone knows of an example, or could help point me in the right direction, I'd greatly appreciate it.

Comments

  • design219design219 Member Posts: 2,273
    I haven't done this with color, but it should be very similar to the fade in, fade out, except using the color instead of the alpha.

    http://gamesalad.com/wiki/how_tos:gsc_fade_image_in_and_out?s[]=fade
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Yeah, just figure out how the R, G, and B values need to change to do the color change. So when you compare color1 to color2 is R a higher value for color2? If so have a behavior that says

    when self.color.red is < (final red color value)
    Timer (every)
    .1 seconds

    change attribute self.color.red to self.color.red+0.1

    get the idea? Good luck!
  • RacetotheMoonRacetotheMoon Member Posts: 323
    Thanks for the (lightning) quick replies, guys. I saw this demo, but got a little hung up on the first image for Fading Out where the equation for the change attribute is partially shown. They have the text below, but since I am rather junior I wasn't able to translate it.

    'Alpha attribute of the actor to the Color → Alpha minus some constant,c, every x number of seconds.'

    I'm not sure how that should look in the expression editor. Also, shouldn't this be a Constrain Attribute rather than a Change Attribute?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    if it is in a timer set to "every" change attribute will be more efficient.
Sign In or Register to comment.