Can someone help me by telling me how to add a share option into my GameScene? I have a button which is a SKSpriteNode but I can not set it up so it will open the share option for Facebook, Twitter etd. I am trying to present a viewcontroller which is the activityViewController but it does not work in the gameScene. Can anyone help with this please? thanks in advance! Also I do not know how to hide and unhide a UIbutton in the GameScene. Thanks.
Asked
Active
Viewed 118 times
1 Answers
0
in GameScene put this in your touchesBegan method
NOTE- that shareBtn is var shareBtn = SKSpriteNode()
for touch in touches {
if isDead == true {
let location = touch.location(in: self)
if shareBtn.contains(location) {
if var top = scene?.view?.window?.rootViewController {
while let presentedViewController = top.presentedViewController {
top = presentedViewController
}
let activityVC = UIActivityViewController(activityItems: ["Can you beat my Score of \(score) in Crappy Duck?"], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
top.present(activityVC, animated: true, completion: nil)
}
}
}
}
i dont really know why this works i got it from this question

E. Huckabee
- 1,788
- 1
- 13
- 29