I've a problem with creating an SKSpriteNode with an UIImage. I'm creating the assets I use for my App with PaintCode (PaintCode creates a Swift file with drawing methods and image methods which allow me to display the created images).
My problem now is that I want to create a simple SKSpriteNode using my PaintCode images but I don't know how to add them to the SpriteNode.
I tried something like this (line 18):
let Bottom = SKSpriteNode(texture: SKTexture(image: StyleKitName.drawBottom(frame: CGRect(x: 50, y: 50, width: 50, height: 50), isWinter: false)))
But it returns following error:
/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: ())'
The StyleKitName.drawBottom function returns an UIImage. It would be nice if anyone could tell me how to create a SKSpriteNode with an UIImage.
I appreciate any help. Thanks.
If you have a UIImage, you can make a sprite node with it likewise:
let Image = //do your setup here to make a UIImage
let Texture = SKTexture(image: Image)
let Sprite = SKSpriteNode(texture:Texture)
Im not sure where or how you called the methods, but I can assure that these are the correct initializers.