简体   繁体   中英

SKShapeNode with swift for iOS 7.1

after coding a game for iOS 8 with swift I decided to test it on iOS 7.1.

First I got an error for initializing SKLabelNode like this:

var myLabel: SKLabelNode = SKLabelNode(text: "test")

I corrected it to work with iOS 7.1 like this

var myLabel: SKLabelNode = SKLabelNode()
myLabel.text = "test"

Unfortunately I do not know how to do the same fix with my SKShapeNodes

My code:

var myShapeNode: SKShapeNode = SKShapeNode(rect: myRect)

How can I make my rectangular SKShapeNode work with iOS 7.1? I tried using the myShapeNode.path but it did not work out...

Thanks for your help

You do not gave the example of how you work with Path, but the example below should work well for IOS 7.1 (in this case CGRectMake is equivalent to your myRect)

let rect: SKShapeNode = SKShapeNode()
let path = CGPathCreateMutable()
CGPathAddRect(path, nil, CGRectMake(0,0,100,100))
rect.path = path

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