Creating a subclass of SKShapeNode

后端 未结 1 1281
庸人自扰
庸人自扰 2021-01-15 04:37
class ColorRectangle: SKShapeNode {

    var width: CGFloat!
    var height: CGFloat!
    var rectColor: UIColor!

    convenience init(rectOfSize: CGSize, colorOfRe         


        
1条回答
  •  野的像风
    2021-01-15 05:28

    Try changing your initializer like this:

    class ColorRectangle: SKShapeNode {
    
        var width: CGFloat!
        var height: CGFloat!
        var rectColor: UIColor!
    
        convenience init(rectOfSize: CGSize, colorOfRectangle rectColor: UIColor) {
    
            self.init()
    
            self.init(rectOfSize: rectOfSize)
    
            self.rectColor = rectColor
    
            self.fillColor = rectColor
            self.strokeColor = rectColor
        }
    
    }
    

    0 讨论(0)
提交回复
热议问题