1
我做了兩個按鈕(leftBtn和rightBtn)。當按下並按下時,它們工作得很好。但是,當您按住時,然後將手指從按鈕上移開並按下,按鈕保持不動?SpriteKit按鈕保持按下
這裏是兩個觸的代碼,並觸
func touchDown(atPoint pos : CGPoint) {
let rightBtn = childNode(withName: "rightBtn");
let leftBtn = childNode(withName: "leftBtn");
if(rightBtn?.frame.contains(pos) == true){
right = true;
}
else if(leftBtn?.frame.contains(pos) == true){
left = true;
}
}
func touchMoved(toPoint pos : CGPoint) {
}
func touchUp(atPoint pos : CGPoint) {
let rightBtn = childNode(withName: "rightBtn");
let leftBtn = childNode(withName: "leftBtn");
if(rightBtn?.frame.contains(pos) == true){
right = false;
carController.stopMove();
}
else if(leftBtn?.frame.contains(pos) == true){
left = false;
carController.stopMove();
}
}