我开始使用新的 Spritekit 框架在 Xcode 中开发我的塔防项目,我想在玩家将创建的任何塔周围添加一个可见的半径(圆圈)。
所以我创建了以下代码:
// Place Towers
-(void)mouseUp:(NSEvent *)theEvent {
/* Called when a mouse click occurs */
CGPoint location = [theEvent locationInNode:self];
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"tower"];
sprite.position = location;
sprite.scale = 1.5;
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
CGContextAddArc(myContext, location.x, location.y, 10, 0, M_PI*2, YES);
CGContextSetRGBStrokeColor(myContext, 0, 0, 225, 0);
[self addChild:sprite];
}
我对角度和其他东西不熟悉,因为我是第一次这样做,所以我只是猜测它应该是这样的。我很确定我错过了什么。
感谢您的任何建议(我等待一些很好的批评)。