Confused About Colors
by Chase Webb · in Torque 2D Beginner · 04/10/2013 (5:46 am) · 5 replies
Hopefully an easy question. What command do I add in to this:
To edit the object (sprite)'s color in this manner? I don't mean to use stock colors in this instance. I've scavenged the wiki without much luck.
%object.COMMANDHERE = 255 128 128 1.0;
To edit the object (sprite)'s color in this manner? I don't mean to use stock colors in this instance. I've scavenged the wiki without much luck.
#2
04/10/2013 (3:09 pm)
And another note, if you leave out the last element of the string in %object.blendColor (%object.blendColor = "255 255 0" for instance) then it is set to maximum - unless something changed.
#3
It's pretty simple, a randomized scrolling background, and a copy of the PointForce Toy's planetoid in the middle. Currently I'm testing the color of the planetoid, as you can see in the /Modules/MyModule/2/scripts/bodynode.cs file:
I have been switching out which piece of code is commented out to see how the different colors look. I'm using the color.cc file's listings as a reference for the values.
Now here's the problem. If I want to use the values for Red, Yellow, Blue, Green, or Purple they show up perfectly. If I put in the value for Orange it shows up as Yellow. If I load it via the StockColorItem name it loads the color as Orange. Here are how the values show up for the Green spectrum (the second value):
255, 0, 0, 1.0 is Red.
255, 1, 0, 1.0 is Yellow.
255, ANYTHING, 0, 1.0 is still Yellow.
So, is this a bug that I need to report? Or is there something flawed in what I am doing?
04/11/2013 (5:48 am)
Thanks everyone! Now I'm having a problem, and want to know if anyone can find out why. Here is a copy of my test project: https://dl.dropboxusercontent.com/u/18965446/RBY%20Food%20Test2.zipIt's pretty simple, a randomized scrolling background, and a copy of the PointForce Toy's planetoid in the middle. Currently I'm testing the color of the planetoid, as you can see in the /Modules/MyModule/2/scripts/bodynode.cs file:
//yellow
//%object.setBlendColor(255, 255, 0, 0.7);
//red
//%object.setBlendColor(255, 0, 00, 0.7);
//blue
//%object.setBlendColor(0, 0, 255, 0.7);
//color tests
//Green
//%object.setBlendColor(0, 255, 0, 0.7);
//Orange
%object.setBlendColor(255, 165, 0, 1.0);
//
//%object.setBlendColor(0, 0, 255, 0.7);
//%object.setBlendColor("Orange");I have been switching out which piece of code is commented out to see how the different colors look. I'm using the color.cc file's listings as a reference for the values.
Now here's the problem. If I want to use the values for Red, Yellow, Blue, Green, or Purple they show up perfectly. If I put in the value for Orange it shows up as Yellow. If I load it via the StockColorItem name it loads the color as Orange. Here are how the values show up for the Green spectrum (the second value):
255, 0, 0, 1.0 is Red.
255, 1, 0, 1.0 is Yellow.
255, ANYTHING, 0, 1.0 is still Yellow.
So, is this a bug that I need to report? Or is there something flawed in what I am doing?
#4
This works correctly.
04/11/2013 (6:15 am)
Thanks to Xifos on the IRC Channel, we found out what I was doing wrong:%object.setBlendColor(255/255, 165/255, 0/255, 1.0);
This works correctly.
#5
What you have there is equivalent to
Huh... that's new - But it is clearly documented in the definition:
04/11/2013 (11:07 pm)
Then it seems that all parameters are supposed to be floating point values from 0.0 to 1.0.What you have there is equivalent to
%object.setBlendColor(1.0, 0.647, 0.0, 1.0);
Huh... that's new - But it is clearly documented in the definition:
ConsoleMethod(SceneObject, setBlendColor, void, 3, 6, "(float red, float green, float blue, [float alpha = 1.0]) or ( stockColorName ) - Sets the blend color."
"@param red The red value.\n"
"@param green The green value.\n"
"@param blue The blue value.\n"
"@param alpha The alpha value.\n"
"@return No return Value.")from SceneObject_ScriptBinding.h @ around line 3200.
Torque Owner Justin Proffitt
OR you can edit the property "blendColor" directly, so:
Note that in the latter case the color is a string.
Edit: Looked up syntax, setBlendColor normally takes four parameters, not sure if it breaks up a string.