【发布时间】:2019-01-27 07:32:15
【问题描述】:
我正在制作一个游戏,我想从我的MenuScene.swift(这是一个 SKScene)文件中展示一个UIView(用于我游戏中的共享场景)。我在 Stack Overflow 上搜索过类似的问题,但没有一个在我的游戏中起作用。谁能告诉我它是如何完成的?
菜单场景:
class MenuScene: SKScene {
override func didMove(to view: SKView) {
backgroundColor = UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha: 1.0)
addLabelsAndButtons()
}
func addLabelsAndButton() {
let shareButton = SKSpriteNode(imageNamed: "ShareButton")
shareButton.size = CGSize(width: frame.size.height/12, height: frame.size.height/12)
shareButton.position = CGPoint(x: frame.midX + shareButton.size.width/1.5, y: frame.minY + shareButton.size.height)
shareButton.name = "ShareButton"
addChild(shareButton)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if atPoint((touch.location(in: self))).name == "ShareButton" {
//Where I want to present my Share Scene!
}
}
}
【问题讨论】: