RaNdOm colors

Popinjay

  • Posts: 27

How would I go about creating random colors in stencyl?

In as3 I would produce random RGB values, but the tinting function in stencyl seems to want me to select a color directly.  Is there any way to make it take an RGB value?

Pop

Luyren

  • *
  • Posts: 2813
Use a code block to set a color attribute (you can use the preview code tab to check how it's done, in case you don't know). This "setter" will use three numbers for the RGB. You generate the numbers randomly and set the color.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

Cocog232

  • Posts: 40
Yon can use random numbers to make random colors :

Xietao

  • Posts: 725
I'd recommend you to change 2-5 if to otherwise if
Free Time:
Monday, Wednesday, Friday: 13h
Tuesday, Thursday, Saturday, Sunday: 7h
Loving Linux...

Popinjay

  • Posts: 27
I suppose my question was phrased badly.  I am no so interested in generating random color as I am in using a variable to generate a color.  I just thought that was the easiest way to present the problem.  I actually wanted to make an actor cycle slowly through a spectrum of colors.  It would be hundreds of if-then statements (about 750 for what I want), although theoretically it could be done that way.

Pop

rob1221

  • *
  • Posts: 9473
You'll have to use code as Luyren said to change the RGB values.  To do what you want you'll need timers to control when and how fast the RGB values change.  You might need a separate variable for each number but I'm not sure.

Popinjay

  • Posts: 27
The problem is I don't know what to assign the number to, because I don't know the name of the movie-clip that actionscript is using for the actor image.

But I haven't tried looking at the generated code and modify it yet, as suggested.  That may reveal what to do.

Pop

rob1221

  • *
  • Posts: 9473
You may also want to check out api.stencyl.com.  Also, Stencyl flash games use Flixel.

aprotasenya

  • Posts: 10
How would I go about creating random colors in stencyl?

If the question is still floating, it's perfectly answered here:
http://community.stencyl.com/index.php/topic,4185.0.html