【发布时间】:2015-08-09 16:44:16
【问题描述】:
我在使用 UIImage 创建 SKSpriteNode 时遇到问题。 我正在使用 PaintCode 创建用于我的应用程序的资产(PaintCode 创建一个 Swift 文件,其中包含允许我显示创建的图像的绘图方法和图像方法)。
我现在的问题是我想使用我的 PaintCode 图像创建一个简单的 SKSpriteNode,但我不知道如何将它们添加到 SpriteNode。
我尝试过这样的事情(第 18 行):
let Bottom = SKSpriteNode(texture: SKTexture(image: StyleKitName.drawBottom(frame: CGRect(x: 50, y: 50, width: 50, height: 50), isWinter: false)))
但它返回以下错误:
/Users/myMacName/Documents/App Development/AppName/AppName/GlobalFunctions.swift:18:44: Cannot find an initializer for type 'SKTexture' that accepts an argument list of type '(image: ())'
StyleKitName.drawBottom 函数返回一个 UIImage。 如果有人能告诉我如何使用 UIImage 创建 SKSpriteNode,那就太好了。
感谢您的帮助。谢谢。
【问题讨论】:
-
你在哪里使用
let Bottom = SKSpriteNode(texture: SKTexture(image: StyleKitName.drawBottom(frame: CGRect(x: 50, y: 50, width: 50, height: 50), isWinter: false)))这行代码? -
这行代码是第18行,同一行出现错误。
标签: ios swift uiimage skspritenode paintcode