如何在Sprite-kit中画一条线 [英] How to draw a line in Sprite-kit
本文介绍了如何在Sprite-kit中画一条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Sprite-kit中画一条线?例如,如果我想在cocos2d中绘制一条线,我可以轻松地使用 ccDrawLine();
How can one draw a line in Sprite-kit? For example if I want to draw a line in cocos2d, I could easily using ccDrawLine();
是否有sprite-kit中的等价物?
Is there an equivalent in sprite-kit?
推荐答案
使用 SKShapeNode 你可以绘制线条或任何形状。
Using SKShapeNode you can draw line or any shape.
SKShapeNode *yourline = [SKShapeNode node];
CGMutablePathRef pathToDraw = CGPathCreateMutable();
CGPathMoveToPoint(pathToDraw, NULL, 100.0, 100.0);
CGPathAddLineToPoint(pathToDraw, NULL, 50.0, 50.0);
yourline.path = pathToDraw;
[yourline setStrokeColor:[SKColor redColor]];
[self addChild:yourline];
这篇关于如何在Sprite-kit中画一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文