简体   繁体   中英

GAME in SWIFT 2 - beginner - UIBezierPath

I want to build a game in swift 2. This could be very silly , but i want to build a rectangle SKShapeNode with no filling out, just borders. I tried to create before a UIBezirPath like this:

    wall = UIBezierPath(rect: CGRect(origin: CGPoint(x: self.frame.width/3, y: self.frame.height/3 ), size: CGSize(width: 30.0, height: 40.0)))
lock = SKShapeNode(path: wall.CGPath)
        lock.strokeColor = SKColor.grayColor()
        lock.lineWidth = 10
        //lock.zRotation = 3.14/4
        //lock.zPosition = 2.0
        self.addChild(lock)

however , the origin of the path is not in the center of my rectangle, but one of the vertices. So my first problem is to centralize this object in my frame.view ;the second one is : Why when i change the zRotation, the object desapears? I would like to make a rectangle with just the borders alliengd with the borders of my view(iphone 6s) , so how could i rotate this object?Thanks in advance for the attention.

I believe it's as simple as setting the fill color of your SKShapeNode to UIColor.clearColor().

let rectangle = SKShapeNode(rectangleOfSize: CGSize(30, 40))
rectangle.fillColor = UIColor.clearColor()
rectangle.strokeColor = UIColor.grayColor()
rectangle.strokeWidth = 10
self.addChild(rectangle)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM