所以每当我有这个:
let result = SKScrollingNode(color: UIColor.clearColor(), size:CGSizeMake(CGFloat(containerWidth), image.size.height));
我收到 image.size.height 的编译错误,告诉我“'UIImage?' 没有名为“size”的成员,尽管它有
知道这意味着什么以及如何解决吗?
谢谢!
整个代码片段:
class func scrollingNode(imageNamed: String, containerWidth: CGFloat) -> SKScrollingNode {
let image = UIImage(named: imageNamed);
let result = SKScrollingNode(color: UIColor.clearColor(), size: CGSizeMake(CGFloat(containerWidth), image.size.height));
result.scrollingSpeed = 1.0;
var total:CGFloat = 0.0;
while(total < CGFloat(containerWidth) + image.size.width!) {
let child = SKSpriteNode(imageNamed: imageNamed);
child.anchorPoint = CGPointZero;
child.position = CGPointMake(total, 0);
result.addChild(child);
total+=child.size.width;
}
return result;