[Resolved] setBlendColor not working on object
by David Helmer · in iTorque 2D · 05/27/2012 (1:46 am) · 6 replies
I call this code where %isEnabled = false
and colors are set in a script already executed here:
and while the console says:
the end result is that the blendColor is set to "255 255 255" rendering the image normally rather than the desired darkened image
this is perplexing in that other code
for
works just fine
How can I work around this issue?
Cheers,
David
and colors are set in a script already executed here:
$lightColor = "255 255 255"; $darkColor = "50 50 50"; $rgbYellow = "251 228 0"; $rgbRed = "255 0 0";
%this.isEnabled = %isEnabled;
if(%isEnabled){
echo("light" SPC $lightColor);
%this.setBlendColor($lightColor);
} else {
echo("dark" SPC $darkColor);
%this.setBlendColor($darkColor);
echo("blendstatus" SPC %this.getBlendingStatus());
echo("blendColor" SPC %this.getBlendColor());
}on the following objectnew t2dStaticSprite(humanSlotButton) {
imageMap = "goArrowImageMap";
frame = "0";
mUseSourceRect = "0";
sourceRect = "0 0 0 0";
canSaveDynamicFields = "1";
PlatformTarget = "UNIVERSAL";
class = "slotButton";
UseMouseEvents = "1";
Position = "-336.000 298.229";
size = "62.000 59.000";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
CollisionMaxIterations = "3";
AlphaTestValue = "-1";
mountID = "19";
};and while the console says:
dark 50 50 50 blendstatus 1 blendColor 50.000000 50.000000 50.000000 1.000000
the end result is that the blendColor is set to "255 255 255" rendering the image normally rather than the desired darkened image
this is perplexing in that other code
function buttonText::setSelected(%this, %isSelected){
if (%isSelected){
%this.setBlendColor($rgbRed);
} else {
%this.setBlendColor($rgbYellow);
}
}for
new t2dStaticSprite() {
imageMap = "btnCampaignImageMap";
frame = "0";
mUseSourceRect = "0";
sourceRect = "0 0 0 0";
canSaveDynamicFields = "1";
PlatformTarget = "UNIVERSAL";
class = "buttonText";
UseMouseEvents = "1";
Position = "0.000 198.000";
size = "181.000 34.000";
GraphGroup = "3";
CollisionMaxIterations = "3";
BlendColor = "1 0 0 1";
AlphaTestValue = "-1";
buttonID = "campaign";
mountID = "15";
};works just fine
How can I work around this issue?
Cheers,
David
About the author
A C# developer by day and a TorqueScript developer by night...
#2
Just change $darkcolor to "0.2 0.2 0.2"
Here's a very handy utility called ColorTorque for converting between color ranges:
www.garagegames.com/community/blogs/view/14593
Echoing your values to the console before you applied them probably made this harder to track down. Instead you should have echoed %this.getBlendColor() to see what color was actually applied to the object - that would have given you a clue as to what Torque is really doing. ;-)
05/27/2012 (7:26 pm)
SetBlendColor takes values from 0 to 1, not 0 to 255. Confusing I know, since the editor's color picker uses 0 to 255 range colors.Just change $darkcolor to "0.2 0.2 0.2"
Here's a very handy utility called ColorTorque for converting between color ranges:
www.garagegames.com/community/blogs/view/14593
Echoing your values to the console before you applied them probably made this harder to track down. Instead you should have echoed %this.getBlendColor() to see what color was actually applied to the object - that would have given you a clue as to what Torque is really doing. ;-)
#3
Any idea as to why the text one works fine for the Yellow and Red?
05/27/2012 (7:32 pm)
Great, thanks for the tip, I'll try that out. Any idea as to why the text one works fine for the Yellow and Red?
#4
05/28/2012 (1:59 am)
Still confused about the text getting set correctly but otherwise thank you very much Conor, that worked and I'm very pleased with the results.
#5
05/30/2012 (6:56 pm)
For the yellow and red it's interpreting the 0 as 0 correctly, and the higher numbers as 1, which still gives you yellow and red.
Torque Owner David Helmer
The Kids