Hello,
The reason it is animating the color to a black tint, is because you are using SP_COLOR_PART_XXXX() when it is unnecessary in these specific methods. SP_COLOR_PART_XXXX() is only necessary if you want to convert a full hex color value to the specific color component. Example: SP_COLOR_PART_GREEN(0x00ff00) would convert to 255.
If you were to leave the majority of your code intact, you could just use the full hex value for the target values, like so:
//red: 60 green: 20 blue: 50 = 3C1432
tween = [SPTween tweenWithTarget:background time:1];
[tween animateRedWithTargetValue:0x3C1432];
[tween animateGreenWithTargetValue:0x3C1432];
[tween animateBlueWithTargetValue:0x3C1432];
[tween animateAlphaWithTargetValue:1];
[Sparrow.juggler addObject:tween];
Also, SP_COLOR_PART_ALPHA() is unneeded in this case also, since it applies to hex values, so the method should be like this:
-(void)animateAlphaWithTargetValue:(uint)value{
[self animateProperty:@"alpha" targetValue:value];
}
That should make the color far less black, but in my color-blind eyes, I still see that this color is pretty dark. Test the color here, if you are interested: http://www.javascripter.net/faq/rgbtohex.htm
Alternatively, like I suggested, you could do without any of the SP_COLOR_PART_XXXX() macros, and I think that would be the logical route to take, here is the complete code:
- (void)animateRedWithTargetValue:(uint)value {
[self animateProperty:@"redColor" targetValue:value];
}
- (void)animateGreenWithTargetValue:(uint)value {
[self animateProperty:@"greenColor" targetValue:value];
}
- (void)animateBlueWithTargetValue:(uint)value {
[self animateProperty:@"blueColor" targetValue:value];
}
-(void)animateAlphaWithTargetValue:(uint)value{
[self animateProperty:@"alpha" targetValue:value];
}
SPImage *background = [[SPImage alloc] initWithTexture:texture];
SPTween * tween = [SPTween tweenWithTarget:background time:1];
[tween animateRedWithTargetValue:60];
[tween animateGreenWithTargetValue:20];
[tween animateBlueWithTargetValue:50];
[tween animateAlphaWithTargetValue:1];
[Sparrow.juggler addObject:tween];
The code above removes the SP_COLOR_PART_XXXX() macros.
Also, be sure that the "setRedColor:", "setGreenColor:", and "setBlueColor:" methods are using SP_COLOR(). And "redColor", "greenColor", "blueColor" methods are using the appropriate SP_COLOR_PART_XXXX(self.color) macros. I assume you are using the code I provided in SHAnimatedColor extension, so that part should be fine.
Note that I removed this line in your code:
SPTween * tween = [[SPTween alloc]init];
This line is unneeded, because you allocate the tween again with the following line:
tween = [SPTween tweenWithTarget:background time:1];
If you are having trouble understanding objective-c allocations, you might need to read up on some of the basics.