###前提・実現したいこと
iphoneの画面をドラッグして、座標をリアルタイムで表示したいです。
###発生している問題・エラーメッセージ
出てきた座標が消えずに重なってしまう。 次の入力があった時に消したいと思っていたので let posit = SKLabelNode() の上にSKAction.removeFromParent()等で消せば良いと思ったのですが実行時点ではpositがなく、消せないということでした。 どうすれば次回入力時にpositを消せるでしょうか。
###該当のソースコード
swift
1 func touchDown(atPoint pos : CGPoint) { 2 } 3 4 func touchMoved(toPoint pos : CGPoint) { 5 6 let posit = SKLabelNode() 7 posit.position = CGPoint(x:self.size.width/2,y:self.size.height/2) 8 posit.fontSize = 60 9 posit.text = "[\(String(describing: pos.x)),\(String(describing: pos.y))]" 10 self.addChild(posit) 11 12 } 13 func touchUp(atPoint pos : CGPoint) { 14 } 15 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 16 for t in touches { self.touchDown(atPoint: t.location(in: self)) } 17 } 18 override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { 19 for t in touches { self.touchMoved(toPoint: t.location(in: self)) } 20 } 21 override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { 22 for t in touches { self.touchUp(atPoint: t.location(in: self)) } 23 } 24 override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { 25 for t in touches { self.touchUp(atPoint: t.location(in: self)) } 26 } 27 override func update(_ currentTime: TimeInterval) { 28 // Called before each frame is rendered 29 } 30
###試したこと
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。