在斯卡拉我有这个功能:
def handleCollision {
walls.foreach(w => if (curPlayer.intersects(w)) {
curPlayer.setLocation(playerStartPos._1, playerStartPos._2)
updateLives(-1)
})
obstacles.foreach(o => if (curPlayer.intersects(o)) {
curPlayer.setLocation(playerStartPos._1, playerStartPos._2)
updateLives(-1)
})
} // End "handleCollision"
我想要做的是当玩家在我的比赛声明中按下键“c”时:
case 'c' =>
我希望它调用此函数并覆盖上述函数,使其不再工作:
def cheatKey {
walls.foreach(w => if (curPlayer.intersects(w)) {
updateLives(+0)
})
obstacles.foreach(o => if (curPlayer.intersects(o)) {
updateLives(+0)
})
}
谢谢