I have created a subclass called Lines, that inherits from C4Shape. For now, all it does is create a random line when a class method is called.
The intention is that every new line begins at the previous line's pointB
(i.e. end point) in order to make a continuing tree of lines. Eventually, I'll have multiple lines spawn from the same end point, old ones disappear, etc. Here's the code I have so far:
+(Lines *)createLineFromPoint:(CGPoint)startPoint {
CGPoint endPoint = CGPointMake([C4Math randomIntBetweenA:(startPoint.x-50) andB:(startPoint.x+50)],
[C4Math randomIntBetweenA:(startPoint.y-50) andB:(startPoint.y+50)]);
CGPoint linePoints[2] = {startPoint, endPoint};
Lines *newLine = [Lines new];
[newLine line:linePoints]; //This should make newLine a line type, should it not?
newLine.lineWidth = 3.0f;
return newLine;
}
-(void) setup {
[self performSelector:@selector(continueMakingLinesWithLine) withObject:(self) afterDelay:(3.0)];
}
-(void) continueMakingLinesWithLine {
[self.arrayOfLines addObject:[Lines createLineFromPoint:self.pointB]];
}
As far as I can tell, it should loop after the first call to continueMakingLinesWithLine
in the C4WorkSpace; the first call is instantiated with a randomly generated CGPoint.
However, I am having a really hard time properly accessing the pointB
property that was set during the last call to the method.
I received an error that tells me that it is because the C4Shape*(the Lines*) is not of type lines or arc.
However, the instance method should be making it of that type, shouldn't it?