我开始使用新的Spritekit框架开发Xcode中的Tower防御项目,并且我想在玩家创建的任何塔上添加一个可见半径(圆圈)。CGContextAddArc:如何创建圈子?
因此,我创建了下面的代码:
// 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];
}
我不熟悉的角度和其他的东西,因为我做这行的第一次,所以我只是猜测,它应该像那。我很确定我错过了什么。
感谢您的任何建议(我等待一些伟大的批评)。
它会产生预期的结果?如果不是,你会得到什么结果,你期望什么? - *“我只是猜测它应该是这样的”*根本不是问题! –
它不产生任何东西,只是精灵本身,没有圈子..对不起,1,在这里发布时间.. – Ferologics
为什么不使用SKShapeNode? https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKShapeNode_Ref/Reference/Reference.html – prototypical