找到SKSpriteNode

时间:2017-03-16 10:15:41

标签: ios swift sprite-kit

我想将SKShapeNode中的SKScene添加到SKSpriteNodeSKSpriteNode可能已经有一些转换自动转换为SKShapeNode,我不想发生这种转换。我添加了添加后shapenode跳转方式的屏幕截图。我还添加了我的代码,我将形状节点添加为子节点并对节点应用一些相反的变换(在某些情况下工作正常,但例如当我缩放,移动和旋转机器人时,绘图跳转到另一个位置)

    func addMaskPath(_ path: CGPath) {
    let drawing = MaskLayer(withPath: path)
    drawing.zRotation = -zRotation

    drawing.xScale = drawing.xScale / xScale
    drawing.yScale = drawing.yScale / yScale

    drawing.position.x = (drawing.position.x - position.x) / xScale
    drawing.position.y = (drawing.position.y - position.y) / yScale

    drawing.position.y = drawing.position.y*cos(zRotation) - drawing.position.x*sin(zRotation)
    drawing.position.x = -drawing.position.y*sin(zRotation) + drawing.position.x*cos(zRotation)

    cropMask?.eraserMask?.addChild(drawing)
}

MaskLayer是一个SKShapeNode。如何轻松找到SKSpriteNode的转换并以与我的SKShapeNode相反的方式应用它们,以便我的绘图在视觉上保持完全相同?

Screenshot

1 个答案:

答案 0 :(得分:0)

如果您不想让SKShapeNode继承其转化,则不应将SKSpriteNode添加到SKNode

我建议让父母SKSpriteNode抓住您的SKShapeNode并将SKNode添加到父SKSpriteNode而不是CREATE VIEW `data_entry` AS SELECT `sites`.`longitude` AS longitude, `sites`.`latitude` AS latitude, `companiesornaturalperson`.`name` FROM sites INNER JOIN companiesornaturalperson ON sites.contractor = companiesornaturalperson.idCompaniesOrNaturalPerson < / p>