Reputation: 53
How to make a SKSpriteNode only work by touching the screen?
I have already written
var main = SKSpriteNode()
and
main = self.childNode(withName: "main") as! SKSpriteNode
Upvotes: 1
Views: 49
Reputation: 6278
There's three parts to this process.
Getting the touch. This is probably done in the GameScene's touchesBegan, in which you need to find the position of the touch.
Having a Sprite to create. This can be part of a function that creates a SKSprite in the GameScene's top level, so you can call it, or it could be a class of your own that you instance on the touch.
Creating, and then Adding the child to the scene.
I think it's the last part, adding the child to the scene, that you might be missing.
Upvotes: 3