How to change colour of actor every 5 seconds?

Hi everyone, I just wanted to know, how I would change the colour of an actor every 5 seconds, also how would I change the colour of an actor once the scene resets.
Thanks.

Comments

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

    You didn't specify how you want the color to change (cycle through four different colors, choose a random color each time, etc.) but here's one way:

    Timer Every 5 seconds
         Change Attribute self.Color.Red to random(0,255)/255
         Change Attribute self.Color.Green to random(0,255)/255
         Change Attribute self.Color.Blue to random(0,255)/255

    When the scene resets, the actor runs its rules again so just do this without a Timer or Rule:

    Change Attribute self.Color.Red to random(0,255)/255
    Change Attribute self.Color.Green to random(0,255)/255
    Change Attribute self.Color.Blue to random(0,255)/255

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

  • TheTigerTheTiger Member Posts: 53

    @tatiang said:
    You didn't specify how you want the color to change (cycle through four different colors, choose a random color each time, etc.) but here's one way:

    Timer Every 5 seconds
         Change Attribute self.Color.Red to random(0,255)/255
         Change Attribute self.Color.Green to random(0,255)/255
         Change Attribute self.Color.Blue to random(0,255)/255

    When the scene resets, the actor runs its rules again so just do this without a Timer or Rule:

    Change Attribute self.Color.Red to random(0,255)/255
    Change Attribute self.Color.Green to random(0,255)/255
    Change Attribute self.Color.Blue to random(0,255)/255

    Hi, thankyou tatiang, sorry for not being specific, I wanted it to be four different colours, not just any random colour, lets say red, blue, green and pink, so how would I do it like that?

    Thankyou.

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

    Well, you could either import four different images and then pick one at random (e.g. Change Attribute self.Image to random(1,4) -- assuming your images are named 1.png, 2.png, 3.png, and 4.png) or you could change self.Color.Red, self.Color.Green, and self.Color.Blue to specific values depending on the result of changing an attribute to random(1,4).

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

  • TheTigerTheTiger Member Posts: 53

    @tatiang said:
    Well, you could either import four different images and then pick one at random (e.g. Change Attribute self.Image to random(1,4) -- assuming your images are named 1.png, 2.png, 3.png, and 4.png) or you could change self.Color.Red, self.Color.Green, and self.Color.Blue to specific values depending on the result of changing an attribute to random(1,4).

    Ok thankyou for the help.

Sign In or Register to comment.