Ios SKSpriteNode创建一条彩色细线

Ios SKSpriteNode创建一条彩色细线,ios,swift,xcode,sprite-kit,skspritenode,Ios,Swift,Xcode,Sprite Kit,Skspritenode,因此,我在应用程序中使用了3SKSpriteNodefloorSprite,leftWall和righwall 这是我当前使用的代码: let floorSprite = SKSpriteNode()//(imageNamed: "floor") floorSprite.alpha = 0.0 floorSprite.anchorPoint = CGPoint(x: 0.5, y: CGPoint.zero.y) floorSprite.phy

因此,我在应用程序中使用了3
SKSpriteNode
floorSprite
leftWall
righwall

这是我当前使用的代码:

    let floorSprite = SKSpriteNode()//(imageNamed: "floor")
    floorSprite.alpha = 0.0
    floorSprite.anchorPoint = CGPoint(x: 0.5, y: CGPoint.zero.y)
    floorSprite.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: self.frame.size.width, height: floorSprite.size.height + 12))
    floorSprite.physicsBody?.isDynamic = false
    floorSprite.physicsBody?.restitution = 0.4
    floorSprite.position = CGPoint(x: self.frame.minX, y: self.frame.minY + (floorSprite.size.height / 2))
    floorSprite.physicsBody?.contactTestBitMask = 0x1 << 1
    floorSprite.physicsBody?.collisionBitMask = 0x1 << 1
    floorSprite.zPosition = 4
    floorSprite.aspectFillToSize(self.frame.size)
    self.addChild(floorSprite)
    self.floorSprite = floorSprite
    
    let leftwall = SKSpriteNode()
    leftwall.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: 0.1, height: self.frame.size.height*2))
    leftwall.physicsBody?.collisionBitMask = 0x1 << 1
    leftwall.physicsBody?.isDynamic = false
    leftwall.position = CGPoint(x: 0 , y: self.frame.size.height / 2.0)
    leftwall.zPosition = 4
    leftwall.physicsBody?.restitution = 1.0
    self.addChild(leftwall)
    
    let rightwall = SKSpriteNode()
    rightwall.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: 0.1, height: self.frame.size.height*2))
    rightwall.physicsBody?.collisionBitMask = 0x1 << 1
    rightwall.physicsBody?.isDynamic = false
    rightwall.physicsBody?.restitution = 1.0
    rightwall.position = CGPoint(x: self.frame.size.width , y: self.frame.size.height / 2.0)
    rightwall.zPosition = 4
    self.addChild(rightwall)
let floorSprite=SKSpriteNode()/(图像名为:“地板”)
楼板间距α=0.0
floorSprite.anchorPoint=CGPoint(x:0.5,y:CGPoint.zero.y)
floorSprite.physicsBody=SKPhysicsBody(矩形:CGSize(宽度:self.frame.size.width,高度:floorSprite.size.height+12))
floorSprite.physicsBody?.isDynamic=错误
地板Prite.physicsBody?恢复=0.4
floorSprite.position=CGPoint(x:self.frame.minX,y:self.frame.minY+(floorSprite.size.height/2))

floorSprite.physicsBody?.contactTestBitMask=0x1这看起来像是您打开了
SKScene.showPhysics
。。在您的appdelegate(或didmovetoview)中或在您打开它的任何位置关闭此选项,这些行都应该消失


这些都是由你的物理身体造成的:)

你有
.showsPhysics=true
附在场景上的视图吗?@RezaShirazian你是救命恩人。删除了那行,现在一切都结束了,谢谢!:)