TOUR
PRICING
HELP
Stencylpedia
Blocks Guide
Sample Games
Developer Center
FORUMS
CHAT
#MADEINSTENCYL
EDUCATION
SIGN IN
×
Welcome back!
Username or E-mail
Password
(
Forgot?
)
C
OMMUNITY
Home
Issue Tracker
Inbox [0]
New Posts
New Replies
Search
Stencyl Community
→
Stencyl
→
Ask a Question
→
RaNdOm colors
Pages:
1
RaNdOm colors
Popinjay
Posts: 27
April 21, 2012, 07:53:08 am
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
April 21, 2012, 08:03:56 am
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
April 21, 2012, 08:10:33 am
Yon can use random numbers to make random colors :
QUACK ?!
http://www.stencyl.com/game/play/13854
Xietao
Posts: 725
April 21, 2012, 10:42:40 am
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
April 21, 2012, 05:05:29 pm
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
April 21, 2012, 06:04:49 pm
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.
https://twitter.com/Rob1221dev
Popinjay
Posts: 27
April 21, 2012, 06:14:48 pm
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
April 21, 2012, 06:21:59 pm
You may also want to check out api.stencyl.com. Also, Stencyl flash games use Flixel.
https://twitter.com/Rob1221dev
aprotasenya
Posts: 10
June 22, 2013, 02:37:30 pm
Quote from: Popinjay on April 21, 2012, 07:53:08 am
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
Pages:
1