I’m writing a simple 2D game using SpriteKit with Playgrounds for iPad. I’m trying to add a menu button using the following code:
SKSpriteNode(imageNamed: )
How do I point to an image? I’ve tried adding an image to the project using the little plus in the top right-hand corner, but when I do that I get the error “cannot convert value of type ‘UIImage’ to expected argument type ‘String’”. So, how do I point to an image?
You should drag your image to the
Resourcesdirectory.Then you should use name of the file which is
String. That's why you got this error.When you initialize UIImage like that you will see the preview of the image: