0

I am trying to put a rectangle in my game and it isn't showing up. Here is where I declare it and other important variables.

    var rect1: SKShapeNode! = SKShapeNode()
    var blackColor = (SKColor(red:0.00, green:0.00, blue:0.00, alpha:1))
    var screenWidth: CGFloat! = 0
    var screenHeight: CGFloat! = 0

And here is where I give it its properties.

            if screenWidth == 1024{
        rect1 = SKShapeNode(rectOfSize: CGSizeMake(screenWidth/50, screenWidth/23))
    }else if screenWidth == 568 || screenWidth == 480{
        rect1 = SKShapeNode(rectOfSize: CGSizeMake(screenWidth/50, screenWidth/23))
    }else{
        rect1 = SKShapeNode(rectOfSize: CGSizeMake(screenWidth/50, screenWidth/23))
    }

    rect1.fillColor = blackColor
    rect1.alpha = 0
    rect1.physicsBody?.dynamic = false
    rect1.physicsBody?.categoryBitMask = PhysicsCategory.rect1
    rect1.physicsBody?.contactTestBitMask = PhysicsCategory.ball
    rect1.physicsBody?.collisionBitMask = PhysicsCategory.None
    rect1.physicsBody?.usesPreciseCollisionDetection = true
    rect1.position = CGPoint(x: 924.325, y: 678.42)
    self.addChild(rect1)

There is no error, but the rectangle isn't showing up. Any help would be appreciated.

Aidan Kaiser
  • 501
  • 5
  • 17

1 Answers1

3

alpha=0 means it is totally transparent. I guess it is the reason why you don't see it.

Dmitry Klochkov
  • 2,484
  • 24
  • 31