title: Drawing sprites programatically for sprite kit with alpha channel?
body: <p>I'm trying to prototype an app for sprite kit, and it would be advantageous to me to be able to draw the sprites I need programatically for now, and then make actual sprites later.  I've made a rough circle, and when I convert to a UIImage (or CGImage) using renderInContext, it shows up on the sprite view with a black background, ignoring the alpha channel, apparently.  If I add the UIImage to a regular view as a UIImageView, the alpha channel is rendered properly.  I was wondering what I'm doing wrong, or if theres' a workaround for this.</p>
  
  <pre><code>float rockSize = 100;
  
  UIView* drawingView = [[UIView alloc] initWithFrame:CGRectMake(0,0,100,100)];
  drawingView.backgroundColor = [UIColor clearColor];
  
  CALayer* circleLayer = [CALayer layer];
  circleLayer.frame = CGRectMake(0,0,rockSize,rockSize);
  circleLayer.backgroundColor = [Utils getTiledColorFromColor:[UIColor purpleColor]].CGColor;
  circleLayer.cornerRadius = rockSize/2.0;
  circleLayer.masksToBounds = YES;
  
  [drawingView.layer addSublayer:circleLayer];
  
  UIGraphicsBeginImageContextWithOptions(CGSizeMake(rockSize, rockSize), NO, [UIScreen mainScreen].scale);
  CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [UIColor clearColor].CGColor);
  CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0,0,rockSize,rockSize));
  [drawingView.layer renderInContext: UIGraphicsGetCurrentContext()];
  
  UIImage *layerImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  SKSpriteNode *rockNode = [SKSpriteNode spriteNodeWithTexture:[SKTexture textureWithImage:layerImage]];
  CGPoint position = CGPointMake(200,100);
  rockNode.position = position;
  
  [self addChild:rockNode];
  </code></pre>