我正在创建一个游戏,在第一级我希望玩家在某个时间点击圈子。例如:玩家可以获得多少次点击至少15秒。 &安培;当玩家在该特定时间限制内达到最大敲击限制时。然后,祝贺玩家。请给我一些帮助,如何建立这个。 这里有一些试图限制圆圈触摸的代码。
let maxScore = 10
var currentScore = 0
func playerScored(amount: Int) {
currentScore += amount
// I will be playing some sort of sound
// ...
}
override func update(_ currentTime: TimeInterval) {
if currentScore >= maxScore { // Player made it
self.view!.presentScene(SKScene(fileNamed: "WinnerScene"))
}
答案 0 :(得分:0)
我希望您知道UITapGestureRecognizer
查看Apple有关点按UITapGestureRecognizer
的文档,您会得到一些想法
答案 1 :(得分:-1)
UITapGestureRecognizer * singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSingleTap)] autorelease]; singleTap.numberOfTapsRequired = 1; [self.view addGestureRecognizer:singleTap];
UITapGestureRecognizer * doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doDoubleTap)] autorelease]; doubleTap.numberOfTapsRequired = 2; [self.view addGestureRecognizer:doubleTap];
[singleTap requireGestureRecognizerToFail:doubleTap];
- >您可以将其转换为 swift 。