How to draw a line in Sprite-kit

前端 未结 7 1103
长发绾君心
长发绾君心 2020-12-02 18:09

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();

Is there an equivalent in sp

7条回答
  •  佛祖请我去吃肉
    2020-12-02 19:06

    Using SKShapeNode I was able to do this.

    // enter code here
    SKShapeNode *line = [SKShapeNode node];
    
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 50.0, 40.0);
    CGPathAddLineToPoint(path, NULL, 120.0, 400.0);
    
    line.path = path;
    [line setStrokeColor:[UIColor whiteColor]];
    
    [self addChild:line];
    

提交回复
热议问题