5

我试图通过首先将 SKShapeNode 转换为纹理来将 SKShapeNode 转换为 Sprite 节点。然而结果是不可见的精灵。物理主体通常在那里,但没有显示图形。我想我尝试转换 SKShapeNode 的方式有问题,但我想不出是什么。你对出了什么问题有感觉吗?感谢所有帮助!

let createdShape = SKShapeNode(path: path)
createdShape.physicsBody = SKPhysicsBody(edgeLoopFromPath: createdShape.path)
createdShape.physicsBody?.categoryBitMask = PhysicsCategory.Shape
createdShape.physicsBody?.contactTestBitMask = PhysicsCategory.None      
createdShape.name = "paintedArea"
createdShape.strokeColor = shapeBorderColor
createdShape.lineWidth = 5.0
createdShape.fillColor = shapeFillColor
createdShape.alpha = 1.0
createdShape.zPosition = shapeZPosition
let texture = view?.textureFromNode(createdShape)
println(texture?.description)                      
let sprite = SKSpriteNode(texture: texture)
sprite.physicsBody = createdShape.physicsBody
sprite.position = createdShape.position
sprite.color = UIColor.blueColor()
self.addChild(sprite)
4

1 回答 1

0

啊,我明白了!我的z位置错了!创建的形状在我的背景图像之上,但新创建的精灵不在。傻了我...

于 2015-03-09T17:18:49.587 回答