Okay, so, I'm all new to iPhone and stuff, but I'm not even at programming, I have many years of experience with ActionScript 2.0 and 3.0, I want to set up a view, that I can also pass variables to. The view is gonna draw everything with Quartz.
I tried to make another game where I tried to add a pointer to a NSMutableArray to the view class, but it didn't work cause I didn't know how to store an actual class.
I wanted to do like:
[myView setNeedsDisplay];
but I had to do
[(View*)self.view setNeedsDisplay];
didn't really work out in the end...
Okay, so now I got:
- (void) viewDidLoad {
[super viewDidLoad];
viewClass = [[View class] retain];
gameView = [[[viewClass alloc] initWithFrame: CGRectZero] retain];
[gameView setNeedsDisplay];
}
This is in my drawInContext:context, which is fired by drawRect:
Also, my drawRect does [self drawInContext: UIGraphicsGetCurrentContext()];
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
CGContextSetLineWidth(context, 3.0);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGMutablePathRef aPath = CGPathCreateMutable();
CGPathMoveToPoint(aPath, nil, 5, 5);
CGPathAddLineToPoint(aPath, nil, 45, 43);
CGContextAddPath(context, aPath);
CGContextStrokePath(context);
Nothing happens.
Help?
Oh yeah, I get this error: : invalid context
for each time I use those functions. :[
Thanks!