Secret color picker for behaviors
by Joe Rossi · in Torque Game Builder · 01/18/2008 (1:13 am) · 9 replies
I'm not sure if this is documented anywhere yet, but in TGB 1.6 you can add a color picker to your behaviors.
Try something like this in your behavior script
%template.addBehaviorField( myColor, "The color", color, "255 255 255 255" );
I thought this was pretty sweet and that I should post about it.
Try something like this in your behavior script
%template.addBehaviorField( myColor, "The color", color, "255 255 255 255" );
I thought this was pretty sweet and that I should post about it.
#2
01/18/2008 (8:49 pm)
Sweet, didn't know that was possible.
#3
If you have the level editor sources you can go into
tools\levelEditor\scripts\forms\quickEditClasses\quickEditFields\colorPicker.ed.cs
find the function QuickEditColorPicker::onColorPicked
and comment this line:
I hope the TGB team can fix this in the next release.
01/18/2008 (10:40 pm)
The only issue I have with this is that whenever you pick a color it always sets the alpha to 0. It shouldn't really touch the alpha value at all. When the alpha is set to 0, objects tend to become invisible. I edited my TGB scripts to leave the alpha alone when picking colors. If you have the level editor sources you can go into
tools\levelEditor\scripts\forms\quickEditClasses\quickEditFields\colorPicker.ed.cs
find the function QuickEditColorPicker::onColorPicked
and comment this line:
%this.alphaText.setText(mFloatLength(getWord(%color, 3) * 255, 0));
I hope the TGB team can fix this in the next release.
#4
01/19/2008 (11:16 am)
@Joe - You can assign your own defaults in a behavior field, e.g.:if (!isObject(ColorBehavior))
{
%template = new BehaviorTemplate(ColorBehavior);
%template.friendlyName = "Color Behavior";
%template.behaviorType = "Example";
%template.description = "Whatever";
%template.addBehaviorField(myColor, "the color", color, 0 SPC 0 SPC 0 SPC 1);
}This can give you a default opaque color, but also allows you to adjust the alpha if you want to. I think this is more flexible than hard-coding it like you did.
#5
01/19/2008 (1:49 pm)
Remember, colors aren't stored between 0 and 255, but 0 and 1 ;)
#6
My point is that whenever you pick a color, your alpha value will automatically revert to 0. This includes any default value, or any value you manually enter before picking a new color. The color picker GUI should only set the RGB values. It should default to 255/opaque and let the user edit that alpha value if they wish. With the modification I posted above, it works great in my behaviors.
01/20/2008 (8:31 am)
@ DanMy point is that whenever you pick a color, your alpha value will automatically revert to 0. This includes any default value, or any value you manually enter before picking a new color. The color picker GUI should only set the RGB values. It should default to 255/opaque and let the user edit that alpha value if they wish. With the modification I posted above, it works great in my behaviors.
#7
01/20/2008 (8:58 am)
@Joe - I'm not seeing it behave like that. For me, the alpha value is only modified by the alpha slider, and the color picker region modifies the RGB values.
#8
Sweet I didn't even notice there was an Alpha slider until I resized my behavior menu a bit. I thought there was only a box labeled "Alpha" under the R,G,B boxes, to enter an alpha value. Perhaps the slider should go horizontally across the bottom, to prevent people from missing it?
Now the alpha is not reverting to 0 when I uncomment that line. Thanks!
P.S. While we have you here..are there any more Easter Eggs in TGB we should know about? :)
01/20/2008 (4:14 pm)
@Dan, Sweet I didn't even notice there was an Alpha slider until I resized my behavior menu a bit. I thought there was only a box labeled "Alpha" under the R,G,B boxes, to enter an alpha value. Perhaps the slider should go horizontally across the bottom, to prevent people from missing it?
Now the alpha is not reverting to 0 when I uncomment that line. Thanks!
P.S. While we have you here..are there any more Easter Eggs in TGB we should know about? :)
#9
01/20/2008 (4:42 pm)
Well, they aren't intended to be Easter Eggs, so it's hard for me to guess about what features you might not know about. :) One thing I discovered myself not too long ago is the t2dShapeVector object, which I thought was kind of cool (although not fully featured). As I mentioned in my blog post, I'm trying to improve support for it.
Torque Owner Michael Hartlef