【发布时间】:2015-10-07 01:21:28
【问题描述】:
所以我有这个 sprite kit 游戏,它是用 swift 2 编码的。游戏包括从屏幕上掉下来的这些彩色圆圈(绿色、红色、紫色、黄色、蓝色),从相同的高度开始,但开始于不同的宽度。屏幕底部有一个栏,告诉您不要按什么颜色。因此,如果条形图是黄色的,并且您单击黄色圆圈,则您输了。我已经有了失败的实现,但我似乎无法弄清楚如何检测点击的圆圈是否不是栏上的颜色。这是我关于颜色检测的代码。请记住,变量“colorNeeded”是您不想点击的颜色
switch colorNeeded {
case SKColor.redColor():
if Red.containsPoint(location) {
print("Color Needed is Blue, Blue Circle Clicked")
print("Lose, score is: \(score)")
changeColorNeeded()
}
break
case SKColor.blueColor():
if Blue.containsPoint(location) {
print("Color Needed is Blue, Blue Circle Clicked")
print("Lose, score is: \(score)")
changeColorNeeded()
}
break
case SKColor.yellowColor():
if Yellow.containsPoint(location) {
print("Color Needed is Blue, Blue Circle Clicked")
print("Lose, score is: \(score)")
changeColorNeeded()
}
break
case SKColor.greenColor():
if Green.containsPoint(location) {
print("Color Needed is Blue, Blue Circle Clicked")
print("Lose, score is: \(score)")
changeColorNeeded()
}
break
case SKColor.purpleColor():
if Purple.containsPoint(location) {
print("Color Needed is Blue, Blue Circle Clicked")
print("Lose, score is: \(score)")
changeColorNeeded()
}
break
default:
if Purple.containsPoint(location) || Green.containsPoint(location) || Yellow.containsPoint(location) || Blue.containsPoint(location) || Red.containsPoint(location){
score++
("Good Color Clicked")
ChangeCounter++
if ChangeCounter == 5 {
changeColorNeeded()
}
}
break
}
【问题讨论】:
标签: swift colors sprite-kit swift2 skspritenode