【发布时间】:2014-01-13 21:33:40
【问题描述】:
我正在创建一个小游戏,但在尝试画一个圆圈时遇到了很多问题。我想为 osx 做,而不是为 iOs 做。
使用此代码绘制矩形非常简单。
CGSize posBarraVida;
posBarraVida.height = 10;
posBarraVida.width = 100;
SKSpriteNode* barraVida = [[SKSpriteNode alloc] initWithColor:[SKColor redColor] size:posBarraVida];
barraVida.position = CGPointMake(self.size.width/8 + 50, self.size.height - 25.0f);
barraVida.zPosition = 1;
[self addChild:barraVida];
但是我有这个代码来绘制一个圆圈,但是我在尝试将 NSBezierPath 的路径转换为 SKShapeNode 的 CGPathRef 属性时出错。
CGRect box = CGRectMake(0, 0, 100, 100);
NSBezierPath *circlePath = [NSBezierPath bezierPathWithOvalInRect:box];
SKShapeNode *circle = [SKShapeNode node];
circle.path = circlePath.bezierPath; // conversion error
【问题讨论】:
标签: objective-c macos cocoa sprite-kit