简体   繁体   English

适用于iOS 7.1的SKShapeNode和swift

[英]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. 在使用swift为iOS 8编写游戏后,我决定在iOS 7.1上测试它。

First I got an error for initializing SKLabelNode like this: 首先我得到一个错误,初始化SKLabelNode像这样:

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

I corrected it to work with iOS 7.1 like this 我纠正它与iOS 7.1一样

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

Unfortunately I do not know how to do the same fix with my SKShapeNodes 不幸的是,我不知道如何使用我的SKShapeNodes进行相同的修复

My code: 我的代码:

var myShapeNode: SKShapeNode = SKShapeNode(rect: myRect)

How can I make my rectangular SKShapeNode work with iOS 7.1? 如何使我的矩形SKShapeNode与iOS 7.1一起使用? I tried using the myShapeNode.path but it did not work out... 我尝试使用myShapeNode.path但它没有用...

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) 您没有给出如何使用Path的示例,但下面的示例应该适用于IOS 7.1(在这种情况下,CGRectMake等同于您的myRect)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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