Color Inheritance

OrchestralMonkeyOrchestralMonkey Member Posts: 33
edited November -1 in Working with GS (Mac)
How do I have an actor inherit the color of another actor when clicked?

--Lee

Comments

  • netdzynrnetdzynr Member Posts: 296
    Color is kind of a chore because you have to set 3 different attributes (red/blue/green). If I understand what youre trying to do, you have store the color attributes of the first actor in 3 scene or game level attributes so the second actor can read them and set it's color as needed.

    If you're working with a limited number of colors, you can use "codes" to represent each color and rule to determine what color is needed. Kind of like:

    If colorCode = 1
    red = some value
    green = some value
    blue = some value

    If colorCode = 2
    red = some value
    green = some value
    blue = some value

    Etc
  • OrchestralMonkeyOrchestralMonkey Member Posts: 33
    My apologies for not being more specific. What I really need is for the actors to 'swap' colors:

    If actor1 is touched then change actor1's color to actor2's and also change actor2's color to actor1's.

    Hope that clears it up, if not let me know.

    My original train of thought was this:

    If actor1 is touched then 'Change Attribute' self.Color.Red = actor2.Color.Red (and repeat for green and blue values), but I couldn't get that to work (unless I did something wrong).
  • netdzynrnetdzynr Member Posts: 296
    You can do this for non-prototype actors (actors to whom you assign behaviors within a scene, as opposed to their prototypes). You have to unlock the actor's behavior of course, and you access the other actor's color attributes via Current Scene > Layers > Background > Actor Name Here > Color > Red... etc.

    But again, the above will only work at the scene level, not on prototype actors. To switch colors using prototypes, you need to use the above method I mentioned, storing color values in game-level attributes.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    You can use game attribute color attributes for the actors. And have the state of the actions stored as a game attribute as well.

    States:
    0 - Nothing Selected
    1 - One actor selected
    2 - Second Actor Selected

    Here is the demo:

    http://gamesalad.com/game/play/88574
  • OrchestralMonkeyOrchestralMonkey Member Posts: 33
    Thanks CM, I'll give that a try.

    The only thing it looks like I'd need to change is to have the swap occur immediately when one actor is touched instead the swap happening when the second actor is touched.

    I only have three actors (left, middle, right) so whatever the color of the middle is, that is what gets swapped with either the left or right when either of them (left or right) is touched. The left and right actors are active the middle actor is just a container if that makes sense.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Updated the demo. Its on the second scene.

    Still at http://gamesalad.com/game/play/88574
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Yeah, I see, trying to figure that out now. Thanks.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Ok. all fixed.
  • OrchestralMonkeyOrchestralMonkey Member Posts: 33
    CM,

    Thank you so much for the demo. This is exactly what I was trying to achieve. Thank you again.

    --Lee
Sign In or Register to comment.