Change Attribute Self.Color to Self.Health

Homebrew_KidHomebrew_Kid Member Posts: 21
edited March 2014 in Working with GS (PC)

Trying to change the green tint of an actor from 175 down to 50 relative to the health pool; something like this:

If self.health is max at 25,
self.heath{25}(5) + 50 =self.color.green{175}

If self.health is minimal at 0,
self.heath{0}(5) + 50 =self.color.green{50}

Also, displaying text as self.color.green shows it as the number 1 on scene (shouldn't it be 175?). The colors from the color swatch are:
R:0
G:175
B:50
A:255

Decreasing self.health is accomplished by:

No changes in color so far.

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    The Mac version of GameSalad Creator uses numbers between 0 and 1 for self.color. It is probably the same for the PC version.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2014

    RGB values are displayed in a range from 0 to 255. To convert, you divide by 255. So a self.color.green value of 175 should actually be 175/255.

    To vary a color attribute based on another attribute such as health -- and in the ranges you mentioned -- try this:

    constrain attribute self.color.green to ((self.health/25)*(175-50)+50)/255

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Homebrew_KidHomebrew_Kid Member Posts: 21
    edited March 2014

    @tatiang said:
    To convert, you divide by 255. So a self.color.green value of 175 should actually be 175/255.

    Right, I remember seeing a fraction one time when adjusting the constrains...

    This worked :D Going to add some red tint too...

Sign In or Register to comment.