What the what?!
I have created a custom class that is used to draw a series of lines. I want the lines to fade out sequentially. But CCfadeOut or any opacity modifiers do not seem to work.
My simple Path class which is a subclass of CCSprite:
#import "Path.h"
@implementation Path
-(id) initWithPoints:(CGPoint)sP :(CGPoint)eP {
if ((self = [super init])) {
startP = sP;
endP = eP;
}
return self;
}
-(void) draw {
glColor4f(0.00f,0.53f,0.57f,0.2f);
glLineWidth(2.0f);
ccDrawLine(startP, endP);
}
-(void) dealloc {
[super dealloc];
}
@end
...and the implementation in my HelloWorldLayer.m
Path *p = [pathsArray objectAtIndex:0];
[p runAction:[CCFadeOut actionWithDuration:.4]];
The pathsArray contains a reference to each individual path and is looped through to grab each one, then perform this action. Everything works well, I can call each path, I can even move it using CCMoveBy, but the opacity is not affected.
I think i have read that child elements of an object do not inherit its opacity (which seems insane to me), but the Path object does not seem to contain any children...
When I NSLog [[p children] count]; it returns 0.
So I'm not sure if using the draw method technically is creating a child element of my object or if there is some other voodoo going on.
Is there a way to fade out this Path?