这是我的代码:
func backgroundandfield(withTexture: SKTexture) {
let background = SKSpriteNode(color: .clear, size: CGSize(width: 6000, height: 1000))
background.zPosition = -1000
background.position.y = -500
background.position.x = 2500
background.size = CGSize(width: 6000, height: 1000)
self.addChild(background)
let field = SKFieldNode.linearGravityField(withVector: vector3(0, 1, 0))
field.region = SKRegion(size: background.size)
field.position = background.position
field.categoryBitMask = 1
field.isEnabled = true
field.isExclusive = true
field.falloff = 0.4
field.strength = 25
field.name = "field"
self.addChild(field)
}
func initgravity() {
let gfield = SKFieldNode.linearGravityField(withVector: vector3(0, -2, 0))
gfield.isEnabled = true
gfield.isExclusive = false
gfield.strength = 7
self.addChild(gfield)
}
这两个函数均在didmove中调用。我的问题是,播放器节点在另一个字段中时仍被“ gfield”下拉。为什么我的.isExculsive无法正常工作?