【发布时间】:2023-03-03 20:24:01
【问题描述】:
我正在使用SpriteKit,并使用四个按钮创建了这个场景。
如果用户点击其中一个按钮,所选按钮周围应该会出现一个黑色圆圈(并停留在那里)。如果用户选择另一个按钮,前一个圆圈应该会消失,而新按钮会变成一个圆圈。
有人知道怎么做吗?
这是我的代码:
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches{
let locationUser = touch.location(in: self)
if atPoint(locationUser) == blueButton {
}
if atPoint(locationUser) == purpleButton {
}
if atPoint(locationUser) == redButton {
}
if atPoint(locationUser) == orangeButton {
}
}
}
【问题讨论】:
标签: swift button sprite-kit